question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mypy linting errors should not be displayed if they are located in other Python files

See original GitHub issue

Please note that this issue is based on a previous issue for the same problem: #9496 I’ve tried each version of the Python extension that was released after this original issue was fixed, and I see the error in each version.

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2020.2.63072
  • OS and version: Arch Linux
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Relevant/affected Python packages and their versions: mypy
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): jedi
  • Value of the python.languageServer setting: Microsoft

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:

See #9496

I am testing with mixology, which can be cloned from here: https://github.com/sdispater/mixology I view the files mixology/partial_solution.py, mixology/version_solver.py, and mixology/package_source.py. There may be more.

Logs

##########Linting Output - mypy##########
mixology/package.py:17:5: error: Type signature has too few arguments
Found 1 error in 1 file (checked 1 source file)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:8

github_iconTop GitHub Comments

2reactions
AWhettercommented, Feb 19, 2020

Hi @kimadeline. Thanks for the response. Yes there is an error in the code. However the error is being reported in every file that imports it, not just in the file with the error.

To clarify my original issue, there’s an error in mixology/package.py, as you mentioned, on line 17. When viewing mixology/partial_solution.py, mixology/version_solver.py, or mixology/package_source.py VSCode reports that same error on line 17 of each of those files, even though the error is in mixology/package.py.

To outline the example in #9496, an error is added to midi.py, but VSCode reports that error in redblue.py and circuits.py as well, on the line that has the same line number as the error in midi.py.

1reaction
kimadelinecommented, Oct 27, 2020

We mark an issue as a regression if it gets introduced in a new version of the extension, and wasn’t present in earlier releases.

Since this issue was not introduced at the same time as #9496, but rather was present for a long time, it was marked as preexisting.

It sounds like using --follow-imports=silent might fix 1, however we’ll still need to take care of 2 (from the comment above), is that right?

  1. When parsing the output of running mypy on a file, we should exclude errors reported on other files:
  2. Once step 1 is addressed, run mypy with filepaths relative to the workspace directory

In any case, this is not a high-priority issue at the moment, so you are more than welcome to give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common issues and solutions - mypy 0.991 documentation
There are several common reasons why obviously wrong code is not flagged as an error. The function containing the error is not annotated....
Read more >
Mypy not displaying errors when target file has absolute path
Install mypy (I'm using pipenv to generate a virtualenv using pipenv install mypy ) · Run mypy against a relative path to the...
Read more >
Mypy Documentation - Read the Docs
Mypy is a static type checker for Python. Type checkers help ensure that you're using variables and functions in your code correctly. With...
Read more >
Porting Python 2 Code to Python 3 — Python 3.11.1 ...
The reason that / isn't simply translated to // automatically is that if an object defines a __truediv__ method but not __floordiv__ then...
Read more >
Use black, mypy, and pylint to make your Python code more ...
When you write Python code by yourself, you may not pay attention to the styling. ... Found 6 errors in 1 file (checked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found