facebook / pyre-check

Performant type-checking for python.
https://pyre-check.org/
MIT License
6.79k stars 432 forks source link

How to support env['PYTHONPATH'] #864

Open kylinlingh opened 3 months ago

kylinlingh commented 3 months ago

Hi, After setting the environment variable as:

export PYTHONPATH='/absolute/path/to/my/project' 

I used absolute imports in different packages of my Python project. However, when I use pyre_dump(), I notice that the call graph construction fails and it cannot find the actually called functions. code directory:

. |── app │   |── api │   │   |── risk.py │   |── model │   │   |── request.py

code of file app/api/risk.py:

from model.risk_request import RiskRequest

when I change the import as below, pyre will work fine

from ..model.risk_request import RiskRequest

How can I resolve this issue?

stroxler commented 3 months ago

If you expect to be able to import model.risk_request directly, then the search path you need is probably '/absolute/path/to/my/project/app' rather than '/absolute/path/to/my/project'