pyright-python
pyright-python copied to clipboard
Different Python Paths for Local and Github Actions
Hi everybody,
My .pre-commit-config.yaml
looks like this:
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.322
hooks:
- id: pyright
args: ["--pythonpath", ".venv/Scripts/python.exe"]
and this all works fine as long as I execute it locally. As soon as I push it to Github, and Github Actions kicks in,, it does no longer work because pyright cannot find any of the installed packages (=for every single import statement there is a reportMissingImports
error thrown). So I thought I change the config file to this:
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.322
hooks:
- id: pyright
args: ["--pythonpath", ".venv/bin/python"]
This would work on Github, but does no longer work locally.
I was looking through the documentation and could not find a mention of the --pythonpath
argument.
How can I specify the pythonpath such that pyright works both locally and on Github?
I don't know if this helps, or if it's anywhere close to intended usage, but I was struggling with a similar issue (wanting different pythonpath
s) and ended up with this beauty:
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.325
hooks:
- id: pyright
entry: bash -c 'pyright --pythonpath $(python -c "import os,sys; print(os.path.realpath(sys.executable))") "$@"' -
Dup #214
@jobh Thank you for sharing the above entry bash example, that works for me and saved my time!