-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Description
mypy has the ability to selectively ignore type errors with special syntax in a type annotation comment. These comments confuse pyflakes and cause it to emit spurious "undefined name" errors.
Sample code using this mypy feature:
def foo(a: str):
if a == 37:
return ""
return a + ""
foo(37) # type: ignore[arg-type]
(See https://mypy.readthedocs.io/en/latest/error_codes.html#silencing-errors-based-on-error-codes for more detail.)
pyflakes reports undefined names in that type annotation comment:
$ pyflakes pyflakes-test.py
pyflakes-test.py:6: undefined name 'ignore'
pyflakes-test.py:6: undefined name 'arg'
If I change the type annotation comment to
foo(37) # type: ignore
then pyflakes is happy. But I'm not happy, because that will prevent mypy from finding other errors in this line.
Metadata
Metadata
Assignees
Labels
No labels