Closed
Description
Bug Report
When there's a top-level type-ignore with error code, like # type: ignore[no-untyped-defs]
, and --warn-unused-ignores
is passed, this type comment always shows up as an unused ignore, even though the type checking would fail without that comment.
To Reproduce
Create this file:
# type: ignore[no-untyped-def]
def untyped(): pass
Run using mypy test.py --strict
. (which includes --warn-unused-ignores
)
Expected Behavior
This should pass, because removing the type comment causes the no-untyped-def
error to appear.
Actual Behavior
$ mypy test.py --warn-unused-ignores
test.py:1: error: Unused "type: ignore" comment
Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy 0.931, Python 3.9.9, Ubuntu 20.04