Mypy linting errors should not be displayed if they are located in other Python files
See original GitHub issuePlease 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:
- Created 4 years ago
- Reactions:6
- Comments:8
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 viewingmixology/partial_solution.py
,mixology/version_solver.py
, ormixology/package_source.py
VSCode reports that same error on line 17 of each of those files, even though the error is inmixology/package.py
.To outline the example in #9496, an error is added to midi.py, but VSCode reports that error in
redblue.py
andcircuits.py
as well, on the line that has the same line number as the error in midi.py.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?In any case, this is not a high-priority issue at the moment, so you are more than welcome to give it a try.