-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Closed
Copy link
Labels
bugmypy got something wrongmypy got something wrongtopic-type-ignore# type: ignore comments# type: ignore comments
Description
Windows 7, Mypy 0.931, Python 3.8.10
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
aberres, ravwojdyla and KyleKing
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-ignore# type: ignore comments# type: ignore comments