-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent treatment of python.analysis.extraPaths between pylint and pylance #511
Labels
bug
Issue identified by VS Code Team member as probable bug
good first issue
Good for newcomers
needs PR
Comments
@couteau Thanks for reporting, this looks like something we can handle in the variable resolver. Found here: vscode-pylint/src/common/settings.ts Lines 35 to 78 in 4fb723b
|
I have a fix for this, just working out the unit test changes. Will submit PR soon. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Issue identified by VS Code Team member as probable bug
good first issue
Good for newcomers
needs PR
It appears that both pylance and the vscode pylint extension use the
python.analysis.extraPaths
setting when resolving imports, but that treat that setting differently with respect to relative paths and variable expansion. This is creating an issue for me in how to specify a path that is relative to the user's home directory.In Unix-like systems (I'm on MacOS), the "~" character at the beginning of the path means the user's home directory. Pylance will treat a path that is prefixed with "~" correctly, and search the path relative to the user's home directory. Pylint, on the other hand, treats a path starting with "~" as a relative path, and specifically, a path relative to the workspace folder. That results in a search path that looks, for example, like
/usr/src/project/~/anaconda3/envs/myenv/shared/package
, which doesn't work, causing pylint to fail to resolve an import that pylance has no problem with.On the other hand, pylint will recognize and expand the standard vscode settings variable
${userHome}
when evaluatingpython.analysis.extraPaths
and will successfully resolve the imports. In contrast, pylance does not recognize and expand these variables, and will choke on a path that starts with${userHome}
, and reports that imports in that path cannot be resolved.I am currently working around this issue by including in the
python.analysis.extraPaths
the same path twice, once beginning with "~" and once beginning with${userHome}
.I could just make them all absolute paths, starting with my home directory, but I don't like to include personal info like that in a settings file that will be public on GitHub, and even if I were ok with that, the settings file wouldn't work for anyone else who might clone my repo.
In any event, it seems like these two python-related parts of vscode that both use the same setting should treat it the same.
The text was updated successfully, but these errors were encountered: