Skip to content

Regression: Mypy integration highlights errors from other files when editing a Python file #9496

@ambv

Description

@ambv

Environment data

  • VS Code version: 1.41.1 2019-12-18T14:57:51.166Z
  • Extension version (available under the Extensions sidebar): 2020.1.57204
  • OS and version: macOS Mojave 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: mypy 0.750
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): JEDI

Expected behaviour

The Python code editor only highlights errors in the file in question.

Actual behaviour

The Python code editor wrongly highlights unrelated errors found in other files that Mypy checked.

Steps to reproduce:

This GIF shows the error at work (click on it to see better, Shift+Cmd+R to restart the animation). Things to notice:

  • the code was initially free of Mypy errors, as I'm showing
  • making a single type error produces Mypy errors in three files; that's expected and pretty common
  • opening one of those other files (redblue.py) will show an unrelated error on line 39 (which is actually the error from midi.py, the original file we edited)

2020-01-09 23 29 37

To reproduce this yourself, clone aiotone and configure it.

$ git clone https://github.com/ambv/aiotone
$ python3.8 -m venv /tmp/aiotone
$ source /tmp/aiotone/bin/activate
(aiotone)$ poetry install
(aiotone)$ code aiotone.code-workspace

Now, in VScode, you might need to let it know the location of your Python interpreter within your virtualenv. Then, open aiotone/midi.py and make the same mistake I did on line 39. Then, open aiotone/redblue.py and observe the Mypy error from midi.py appear on line 39 in redblue.py, too.

Observations

  1. This regression is not present in the previous release of python-vscode.
  2. When mypy.ini is not present at all, this bug does not manifest.
  3. One commit I found that might be related: 1b6fbfb

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugregressionBug didn't exist in a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions