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
I seems to understand that mypy can detect unused branched (ones checked against sys.version_info) and avoid checking them. However --warn-unused-ignore doesn't apply the same filtering.
As a consequence, an # ignore in a branch that goes unchecked is reported as unused, instead of being ignored. So you can have a statement that is reported as error running mypy with a certain Python version, but, if ignored, the same line will be reported as unneeded with a different Python version.
Running mypy --warn-unused-ignores test.py with Python 3.6, it will report an arg-type error on the last line, whereas a Python 3.8 test run will be clean.
If a type: ignore[arg-type] comment is added to the last line, the Python 3.6 run will be clean, but Python 3.8 will fail with "unused 'type: ignore' comment".
The expectation is that the type: ignore would be ignored by Python 3.8, if such branch is not checked.
Your Environment
Tested with mypy 0.782, 0.790
The text was updated successfully, but these errors were encountered:
Aligning Travis with my current dev environment to avoid cases where
it's not possible to type-check consistently with different Python
versions.
See python/mypy#9652
Aligning Travis with my current dev environment to avoid cases where
it's not possible to type-check consistently with different Python
versions.
See python/mypy#9652
Bug Report
I seems to understand that mypy can detect unused branched (ones checked against
sys.version_info
) and avoid checking them. However--warn-unused-ignore
doesn't apply the same filtering.As a consequence, an
# ignore
in a branch that goes unchecked is reported as unused, instead of being ignored. So you can have a statement that is reported as error running mypy with a certain Python version, but, if ignored, the same line will be reported as unneeded with a different Python version.To Reproduce
Running
mypy --warn-unused-ignores test.py
with Python 3.6, it will report an arg-type error on the last line, whereas a Python 3.8 test run will be clean.If a
type: ignore[arg-type]
comment is added to the last line, the Python 3.6 run will be clean, but Python 3.8 will fail with "unused 'type: ignore' comment".The expectation is that the type: ignore would be ignored by Python 3.8, if such branch is not checked.
Your Environment
Tested with mypy 0.782, 0.790
The text was updated successfully, but these errors were encountered: