Top-level assert does not skip 'type: ignore' comments #8234
Labels
bug
mypy got something wrong
priority-1-normal
topic-reachability
Detecting unreachable code
topic-type-ignore
# type: ignore comments
When using mypy with the --warn-unused-ignore option,
type: ignore
comments are still analyzed, and possibly reported, when occurring afterassert sys.platform == ...
statements.Take the following module as an example:
Running
mypy --warn-unused-ignore --platform win32 test.py
finds no errors, as expected. However,mypy --warn-unused-ignore --platform linux test.py
reports the following error:I would expect (by reading the documentation) that the assert should cause the rest of the file to be skipped, including
type: ignore
comments, since they also are likely platform-specific. The same issue likely occurs forsys.version_info
asserts as well.I am experiencing the issue with Python 3.7.5 and mypy 0.750, 0.760, 0.761, and master.
The text was updated successfully, but these errors were encountered: