You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
# type: ignore[import] at top of file causes all error codes to be ignored #11999
An # type: ignore[import] line at top of file causes all error codes to be ignored, not just that error code.
I'm guessing this was never supposed to work, and is just a side effect of #964. However, (1) this is too confusing and easy-to-miss, (2) this feature would be very useful in my opinion. Sometimes there's just this one error that comes up lots of times in a file and I want to shush just that one without losing the other warnings.
Administrator@Turing MSYS ~/Desktop
$ cat x.py
import numpy
def f(x: str = 3):
return 7
Administrator@Turing MSYS ~/Desktop
$ mypy x.py --show-error-codes
x.py:1: error: Skipping analyzing "numpy": module is installed, but missing library stubs or py.typed
marker [import]
x.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
x.py:3: error: Incompatible default for argument "x" (default has type "int", argument has type "str"
) [assignment]
Found 2 errors in 1 file (checked 1 source file)
Administrator@Turing MSYS ~/Desktop
$ cat y.py
# type: ignore[import]
import numpy
def f(x: str = 3):
return 7
Administrator@Turing MSYS ~/Desktop
$ mypy y.py --show-error-codes
Success: no issues found in 1 source file
For imports at least, configuration files offer some customization, though this might just generally be useful. (especially if mypy gets proper error codes).
Activity
A5rocks commentedon Jan 22, 2022
For imports at least, configuration files offer some customization, though this might just generally be useful. (especially if mypy gets proper error codes).
Warn on module level type ignore with error code
Warn on module level type ignore with error code (#13512)