mypy --exclude not working in settings.json
See original GitHub issueEnvironment data
Version: 1.57.0 Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c Date: 2021-06-09T17:22:31.215Z Electron: 12.0.9 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Darwin x64 19.6.0
Name: Python Id: ms-python.python Version: 2021.6.944021595
Name: Pylance Id: ms-python.vscode-pylance Version: 2021.6.2
mypy 0.902
Expected behaviour
Setting "python.linting.mypyArgs": ["--exclude", "tests"]
in settings.json
disables mypy on the tests/
directory.
Actual behaviour
VSCode detects an error in files under tests/
.
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- Install mypy
- Create a directory
tests/
- Add a python file in there with a mypy error
- Set
"python.linting.mypyArgs": ["--exclude", "tests"]
insettings.json
- Open the file from step 4 and vscode will show a mypy error
When running mypy --exclude tests .
in the terminal, mypy will not show an error
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Exclude folder from mypy checking - python - Stack Overflow
And mypy doesn't use the exclude option when invoked on a single file. The workaround is using python.linting.ignorePatterns in the settings.
Read more >The mypy configuration file - mypy 0.991 documentation
Mypy supports reading configuration settings from a file. ... To refer to the user home directory, use ~ at the beginning of the...
Read more >mypy — Debian unstable
py$' --exclude '/build/'. Note that this flag only affects recursive directory tree discovery, that is, when mypy is discovering files within a ...
Read more >Mypy Documentation - Read the Docs
import json else: import orjson as json # mypy is unaware of this. In some cases type annotations can cause issues at runtime,...
Read more >python/mypy - Gitter
it's the same as I can define an alias X = Tuple[T, T] no problem; but once I want to annotate a variable,...
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
The issue is that VS Code is invoking
mypy
file by file. Andmypy
doesn’t use the exclude option when invoked on a single file. The workaround is usingpython.linting.ignorePatterns
in the settings.json.More info about the behaviour of exclude:
another workaround if you’d prefer to keep linting on in general for a set of files, but disable mypy only, would be to add an empty
--exclude
topython.linting.mypyArgs
. Note there will be significant computational overhead with this approach though since this will result in all non-excluded files (via other configuration, pyproject.toml for instance) being checked for every file checked (every open file with modifications it seems). Any sense of when this bug is targeted for a fix? Thanks!