Skip to content

Mypy messages for other files not filtered out #15216

@sbdchd

Description

@sbdchd

Environment data

  • VS Code version: 1.52.1
  • Extension version (available under the Extensions sidebar): 2021.1.502429796
  • OS and version: Mac OS 10.15
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: mypy
  • Relevant/affected Python-related VS Code extensions and their versions: mypy
  • Value of the python.languageServer setting: pylance

Expected behaviour

Errors returned by mypy for other files are ignored and not shown as errors for the current file.

Actual behaviour

Errors for other files "leak" into the current file.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Create a couple files, one with an unreachable statement
❯ tree foo
foo
├── __init__.py
└── bar.py
# __init__.py
def main() -> None:
    return None
    print("something")
# bar.py
def foo() -> None:
    x: int = "foo"
  1. run mypy via vscode on the file without the unreachable statement

    Should get an error about an unreachable statement in the current file instead of the correct file.

Screen Shot 2021-01-24 at 12 08 25 AM

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

> ~/Downloads/vscode-python-mypy-example/.venv/bin/python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/sortImports.py - --diff
cwd: ~/Downloads/vscode-python-mypy-example/foo
> ~/Downloads/vscode-python-mypy-example/.venv/bin/python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/sortImports.py - --diff
cwd: ~/Downloads/vscode-python-mypy-example/foo
> ~/Downloads/vscode-python-mypy-example/.venv/bin/python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/Downloads/vscode-python-mypy-example/foo/bar.py
cwd: ~/Downloads/vscode-python-mypy-example
> ~/Downloads/vscode-python-mypy-example/.venv/bin/python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/Downloads/vscode-python-mypy-example/foo/bar.py
cwd: ~/Downloads/vscode-python-mypy-example
> ~/Downloads/vscode-python-mypy-example/.venv/bin/python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py mypy --config-file=~/Downloads/vscode-python-mypy-example/mypy.ini ~/Downloads/vscode-python-mypy-example/foo/bar.py
cwd: ~/Downloads/vscode-python-mypy-example
> ~/Downloads/vscode-python-mypy-example/.venv/bin/python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py mypy --config-file=~/Downloads/vscode-python-mypy-example/mypy.ini ~/Downloads/vscode-python-mypy-example/foo/bar.py
cwd: ~/Downloads/vscode-python-mypy-example
##########Linting Output - mypy##########
foo/__init__.py:4:5: error: Statement is unreachable  [unreachable]
foo/bar.py:2:14: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 2 errors in 2 files (checked 1 source file)

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions