You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the recommended way to tell pyright about venv path when using uvx pyright[nodejs]?
When I run that command without proper configuration, I get lots of missing import errors. This suggests that pyright isn't automatically/correctly detecting the project's .venv path. I suspect this issue occurs because uvx runs commands in a temporary environment, isolated from the current project's virtual environment.
I initially fixed this by adding venvPath = "." and venv = ".venv" to the [tool.pyright] section in my pyproject.toml. However, using venvPath is discouraged for specifying the project environment.[1]
uvx pyright[nodejs] --venvpath . fails to detect the environment (there is no --venv option defined for cli call)
Using uvx pyright[nodejs] --pythonpath .venv/Scripts/python works, but it is not straightforward to type and not cross-platform (the path is .venv/bin/python on linux).
BTW, running uvx ty check or uvx pyrefly check works as expected without additional settings, I wonder if pyright can implement the same .venv detection mechanism as those.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is the recommended way to tell
pyrightaboutvenvpath when usinguvx pyright[nodejs]?When I run that command without proper configuration, I get lots of missing import errors. This suggests that
pyrightisn't automatically/correctly detecting the project's.venvpath. I suspect this issue occurs becauseuvxruns commands in a temporary environment, isolated from the current project's virtual environment.I initially fixed this by adding
venvPath = "."andvenv = ".venv"to the[tool.pyright]section in mypyproject.toml. However, using venvPath is discouraged for specifying the project environment.[1]uvx pyright[nodejs] --venvpath .fails to detect the environment (there is no--venvoption defined for cli call)uvx pyright[nodejs] --pythonpath .venv/Scripts/pythonworks, but it is not straightforward to type and not cross-platform (the path is.venv/bin/pythonon linux).BTW, running
uvx ty checkoruvx pyrefly checkworks as expected without additional settings, I wonder ifpyrightcan implement the same.venvdetection mechanism as those.Beta Was this translation helpful? Give feedback.
All reactions