basedpyright
basedpyright copied to clipboard
import resolution for generic virtual environments
First of all, thank you for the awesome project!
I am trying to come to terms with resolution of package imports within virtual environments (which I often found difficult in pyright
as well): in particular I am referring to the import resolution section in the docs. Notice I have read https://github.com/DetachHead/basedpyright/issues/158 and https://github.com/DetachHead/basedpyright/issues/214 as well.
Description
I am using poetry to manage virtual environments: this means that virtual environments are generally created in some local paths ~/Library/pypoetry/virtualenvs/<projectname>-abc124...
(or similar), with python packages locally installed are referred therein.
While running the project within the activated virtual environment, basedpyright always shows the diagnostic "Import
If a venv name is specified along with a python.venvPath setting (or a --venvpath command-line argument), it appends the venv name to the specified venv path...
The documentation moreover mentions
Use the python.pythonPath setting. This setting is defined by the VS Code Python extension and can be configured using the Python extension’s environment picker interface.
which is a little unclear to me if you are not using VS Code (the pythonPath
is not a variable that even exists or is/must be explicitly set).
Attempts
[tool.basedpyright]
typeCheckingMode = "standard"
venvPath = "~/Library/pypoetry/virtualenvs/" (or similar explicit path, or similar grammars)
What is the recommended way to specify paths to virtual environments for package resolution? (Notice I am referring to package imports and not relative imports from other modules, which work fine instead).