Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider changing default Mypy Arguments setting to avoid spurious errors when used with warn_unused_ignores #192

Closed
PeterJCLaw opened this issue Jun 27, 2020 · 3 comments
Labels
feature-request Request for new features or functionality needs PR

Comments

@PeterJCLaw
Copy link
Contributor

Environment data

  • VS Code version: 1.46.1
  • Extension version (available under the Extensions sidebar): 2020.6.90262

Expected behaviour

I generally expect that my editor will give the same linter experience as running a linter directly on the command line.

Actual behaviour

For the case of warn_unused_ignores in combination with a type: ignore comment on an import line, running mypy through VSCode differs from the command line experience and thus from what any scripted runs (including CI) would output. This results from the vscode-python extension passing non-default arguments to mypy which override behaviours the user may have configured in their project.

Steps to reproduce:

# setup.cfg
[mypy]
warn_unused_ignores = True
# demo.py
import asttokens  # type: ignore

print(asttokens)
pip install asttokens==2.0.4 mypy

I'm using asttokens here, but I've seen this with other libraries too (for example parso and jedi). The common theme is that it is a library which doesn't have type annotations.

Command line run:

$ mypy demo.py 
demo.py:9: error: Function is missing a type annotation
Success: no issues found in 1 source file

VSCode Output tab output:

demo.py:1: error: unused 'type: ignore' comment
Found 1 error in 1 file (checked 1 source file)

I had initially assumed that this was a bug in vscode-python and it was only while reviewing the mypy setting to check I didn't have any changes I should include in the bug report that I spotted the non-default arguments which vscode-python passes to mypy.

I can definitely see why the chosen options were set -- to reduce the noise from mypy for new users who may not have configured mypy themselves, however this leads to a non-obvious difference between mypy in the editor and mypy on the command line.

I can see that it may be somewhat reasonable for an editor to have false negatives (or hide errors) relative to the command line, however the issue here is that these options create false positives -- errors in the editor which it is not clear how to resolve and which do not reproduce elsewhere. This leads to a reduction in trust that the editor and/or mypy is reporting the right things.

@PeterJCLaw PeterJCLaw added triage-needed bug Issue identified by VS Code Team member as probable bug labels Jun 27, 2020
@PeterJCLaw
Copy link
Contributor Author

Ah, just realised this ended up as a bug because I didn't switch templates when I worked out what the cause was. Feel free to reclassify as a feature request.

@karthiknadig karthiknadig changed the title Consider changing default Mypy Arguments settng to avoid spurious errors when used with warn_unused_ignores Consider changing default Mypy Arguments setting to avoid spurious errors when used with warn_unused_ignores Jun 29, 2020
@karthiknadig karthiknadig added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Jun 29, 2020
@karthiknadig
Copy link
Member

Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

naa0yama referenced this issue in naa0yama/PythonBoilerplate Jan 12, 2023
naa0yama referenced this issue in naa0yama/PythonBoilerplate Jan 12, 2023
* remove extention Pylance
* set "python.linting.mypyArgs"
https://github.com/microsoft/vscode-python/issues/12619 のワークアラウンド
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Oct 31, 2023
@karthiknadig
Copy link
Member

TOOL_ARGS = [
"--no-color-output",
"--no-error-summary",
"--show-absolute-path",
"--show-column-numbers",
"--show-error-codes",
"--no-pretty",
]

These are the defaults, they are now minimized to only those values that we really need for the server to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality needs PR
Projects
None yet
Development

No branches or pull requests

3 participants