mtshiba / pylyzer

A fast, feature-rich static code analyzer & language server for Python
http://mtshiba.github.io/pylyzer/
MIT License
2.44k stars 32 forks source link

Feature request: Support for searching $PYTHONPATH #91

Open jakeanq opened 5 months ago

jakeanq commented 5 months ago

As far as I can see there is currently no support for searching locations specified on $PYTHONPATH, so this is a request for adding that.

This would be useful in order to be able to typecheck dependencies that live in arbitrary locations or when working with package managers such as nix (I assume nix uses $PYTHONPATH but I haven't actually confirmed this) or rez.

Potentially it could also be useful to be able to specify search paths on the CLI in order to run type checking on a different environment to the one which is running pylyzer.

Ooonry commented 4 months ago

it skam

mtshiba commented 2 months ago

Pylyzer obtains sys.path (including $PYTHONPATH) from the Python interpreter in the current environment to resolve imports. Therefore, if the interpreter settings are correct, $PYTHONPATH should automatically be included in the path candidates for import resolution.

mtshiba commented 2 months ago

The python interpreter used can be changed via tool.pylyzer.python.path in pyproject.toml.

https://github.com/mtshiba/pylyzer/blob/main/docs/source/pyproject.md