pyright-python icon indicating copy to clipboard operation
pyright-python copied to clipboard

Different Python Paths for Local and Github Actions

Open r0f1 opened this issue 1 year ago • 3 comments

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?

r0f1 avatar Aug 14 '23 09:08 r0f1

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 pythonpaths) 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))") "$@"' -

jobh avatar Sep 05 '23 15:09 jobh

Dup #214

ryanpeach avatar Sep 11 '24 00:09 ryanpeach

@jobh Thank you for sharing the above entry bash example, that works for me and saved my time!

921kiyo avatar Sep 15 '24 17:09 921kiyo