microsoft / microsoft/vscode-mypy
PYTHONPATH is corrupted by bundled dependencies dir in mypy process when using mypy-type-checker.path
@karthiknadig is already working on this.
Since Nov 13, 2023.
- Dominant language
- Python
- Stars
- 150
- Forks
- 39
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 8
Description
When `mypy-type-checker.path` is configured to use a user-controlled version of mypy instead of the bundled one, it is invoked with the `PYTHONPATH` env var set to include the extension's bundled python dependencies which causes mypy to return unexpected results as it loads dependencies from the bundled libs in preference to venv or system equivalents.
Configuring this setting with a shell stub to print environment such as
```
#!/bin/sh
env | sort 1>&2
exec ./venv/bin/mypy "$@"
```
reveals
```
PYTHONPATH=/.vscode/extensions/ms-python.mypy-type-checker-2023.6.0/bundled/libs:
```
in the extension's output panel.
The extension setting `importStrategy=fromEnvironment` is affected by a similar bug: https://github.com/microsoft/vscode-black-formatter/issues/369
The other VS Code extensions for black, isort, pylint do not set `PYTHONPATH` and so are correctly isolated from the LSP server python environment.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.