Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show unused-ignore errors in unreachable code, and make it a real error code #15164

Merged
merged 7 commits into from May 2, 2023

Conversation

ilevkivskyi
Copy link
Member

Fixes #8823

The issue above makes --warn-unused-ignores problematic for cross-platform/cross-version code (btw it is one of the most upvoted bugs). Due to how the unused ignore errors are generated, it is hard to not generate them in unreachable code without having precise span information for blocks. So my fix will not work on Python 3.7, where end lines are not available, but taking into account that 3.7 reaches end of life in less than 2 month, it is not worth the effort.

Also this PR makes unused-ignore work much more like a regular error code, so it can be used with --enable-error-code/--disable-error-code (including per-file) etc. More importantly this will also allow to use --warn-unused-ignores in code that uses e.g. try/except imports (instead of if version checks) with the help of # type: ignore[import,unused-ignore] (which btw will also help on Python 3.7).

Note also currently line numbers for Blocks are actually wrong (and hence few TODOs in fastparse.py). So in this PR I set them all correctly and update a lot of parse tests (I went through all test updates and verified they are reasonable).

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is a big usability win and addresses a long-standing issue.

docs/source/error_code_list2.rst Outdated Show resolved Hide resolved
docs/source/error_code_list2.rst Outdated Show resolved Hide resolved
docs/source/error_code_list2.rst Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2023

Diff from mypy_primer, showing the effect of this PR on open source code:

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/exception.py:16: error: Unused "type: ignore" comment
+ pwndbg/exception.py:16: error: Unused "type: ignore" comment  [unused-ignore]

schema_salad (https://github.com/common-workflow-language/schema_salad)
- schema_salad/utils.py:132: error: Unused "type: ignore" comment
+ schema_salad/utils.py:132: error: Unused "type: ignore" comment  [unused-ignore]

poetry (https://github.com/python-poetry/poetry)
- src/poetry/pyproject/toml.py:32: error: Unused "type: ignore" comment
+ src/poetry/pyproject/toml.py:32: error: Unused "type: ignore" comment  [unused-ignore]
- src/poetry/layouts/layout.py:94: error: Unused "type: ignore" comment
+ src/poetry/layouts/layout.py:94: error: Unused "type: ignore" comment  [unused-ignore]
- src/poetry/layouts/layout.py:97: error: Unused "type: ignore" comment
+ src/poetry/layouts/layout.py:97: error: Unused "type: ignore" comment  [unused-ignore]
- tests/utils/test_source.py:37: error: Unused "type: ignore" comment
+ tests/utils/test_source.py:37: error: Unused "type: ignore" comment  [unused-ignore]
- src/poetry/poetry.py:41: error: Unused "type: ignore" comment
+ src/poetry/poetry.py:41: error: Unused "type: ignore" comment  [unused-ignore]
- src/poetry/poetry.py:62: error: Unused "type: ignore" comment
+ src/poetry/poetry.py:62: error: Unused "type: ignore" comment  [unused-ignore]
- src/poetry/console/commands/self/self_command.py:78: error: Unused "type: ignore" comment
+ src/poetry/console/commands/self/self_command.py:78: error: Unused "type: ignore" comment  [unused-ignore]
- tests/packages/test_locker.py:519: error: Unused "type: ignore" comment
+ tests/packages/test_locker.py:519: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:124: error: Unused "type: ignore" comment
+ tests/conftest.py:124: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:133: error: Unused "type: ignore" comment
+ tests/conftest.py:133: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:142: error: Unused "type: ignore" comment
+ tests/conftest.py:142: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:151: error: Unused "type: ignore" comment
+ tests/conftest.py:151: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:157: error: Unused "type: ignore" comment
+ tests/conftest.py:157: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:166: error: Unused "type: ignore" comment
+ tests/conftest.py:166: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:172: error: Unused "type: ignore" comment
+ tests/conftest.py:172: error: Unused "type: ignore" comment  [unused-ignore]
- tests/conftest.py:212: error: Unused "type: ignore" comment
+ tests/conftest.py:212: error: Unused "type: ignore" comment  [unused-ignore]
- tests/integration/test_utils_vcs_git.py:279: error: Unused "type: ignore" comment
+ tests/integration/test_utils_vcs_git.py:279: error: Unused "type: ignore" comment  [unused-ignore]

werkzeug (https://github.com/pallets/werkzeug)
- src/werkzeug/_reloader.py:328: error: Unused "type: ignore" comment
+ src/werkzeug/_reloader.py:328: error: Unused "type: ignore" comment  [unused-ignore]
- src/werkzeug/routing/map.py:789: error: Unused "type: ignore[type-var]" comment
+ src/werkzeug/routing/map.py:789: error: Unused "type: ignore[type-var]" comment  [unused-ignore]

pip (https://github.com/pypa/pip)
- src/pip/_internal/locations/_distutils.py:60: error: Unused "type: ignore" comment
+ src/pip/_internal/locations/_distutils.py:60: error: Unused "type: ignore" comment  [unused-ignore]

pylint (https://github.com/pycqa/pylint)
- pylint/utils/utils.py:353: error: Unused "type: ignore" comment
+ pylint/utils/utils.py:353: error: Unused "type: ignore" comment  [unused-ignore]

SinbadCogs (https://github.com/mikeshardmind/SinbadCogs)
- devtools/patches.py:22: error: Unused "type: ignore" comment
+ devtools/patches.py:22: error: Unused "type: ignore" comment  [unused-ignore]
- devtools/patches.py:30: error: Unused "type: ignore" comment
+ devtools/patches.py:30: error: Unused "type: ignore" comment  [unused-ignore]
- devtools/runner.py:26: error: Unused "type: ignore" comment
+ devtools/runner.py:26: error: Unused "type: ignore" comment  [unused-ignore]
- scheduler/message.py:87: error: Unused "type: ignore" comment
+ scheduler/message.py:87: error: Unused "type: ignore" comment  [unused-ignore]
- scheduler/message.py:89: error: Unused "type: ignore" comment
+ scheduler/message.py:89: error: Unused "type: ignore" comment  [unused-ignore]
- scheduler/message.py:111: error: Unused "type: ignore" comment
+ scheduler/message.py:111: error: Unused "type: ignore" comment  [unused-ignore]
- rolemanagement/core.py:800: error: Unused "type: ignore" comment
+ rolemanagement/core.py:800: error: Unused "type: ignore" comment  [unused-ignore]
- anticommandspam/core.py:136: error: Unused "type: ignore" comment
+ anticommandspam/core.py:136: error: Unused "type: ignore" comment  [unused-ignore]
- scheduler/scheduler.py:116: error: Unused "type: ignore" comment
+ scheduler/scheduler.py:116: error: Unused "type: ignore" comment  [unused-ignore]
- scheduler/__init__.py:31: error: Unused "type: ignore" comment
+ scheduler/__init__.py:31: error: Unused "type: ignore" comment  [unused-ignore]

cloud-init (https://github.com/canonical/cloud-init)
- tests/hypothesis_jsonschema.py:8: error: Unused "type: ignore" comment
+ tests/hypothesis_jsonschema.py:8: error: Unused "type: ignore" comment  [unused-ignore]
- tests/hypothesis.py:10: error: Unused "type: ignore" comment
+ tests/hypothesis.py:10: error: Unused "type: ignore" comment  [unused-ignore]

jinja (https://github.com/pallets/jinja)
- src/jinja2/utils.py:185: error: Unused "type: ignore" comment
+ src/jinja2/utils.py:185: error: Unused "type: ignore" comment  [unused-ignore]
- src/jinja2/environment.py:706: error: Unused "type: ignore" comment
+ src/jinja2/environment.py:706: error: Unused "type: ignore" comment  [unused-ignore]
- src/jinja2/nativetypes.py:109: error: Unused "type: ignore" comment
+ src/jinja2/nativetypes.py:109: error: Unused "type: ignore" comment  [unused-ignore]

rich (https://github.com/Textualize/rich)
- rich/console.py:1311: error: Unused "type: ignore" comment
+ rich/console.py:1311: error: Unused "type: ignore" comment  [unused-ignore]

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
- pandas-stubs/core/series.pyi:1435: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1435: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1449: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1449: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1461: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1461: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1913: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1913: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1914: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1914: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1915: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1915: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1966: error: Unused "type: ignore" comment
+ pandas-stubs/core/series.pyi:1966: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/algorithms.pyi:28: error: Unused "type: ignore" comment
+ pandas-stubs/core/algorithms.pyi:28: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/algorithms.pyi:30: error: Unused "type: ignore" comment
+ pandas-stubs/core/algorithms.pyi:30: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/algorithms.pyi:32: error: Unused "type: ignore" comment
+ pandas-stubs/core/algorithms.pyi:32: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/multi.pyi:116: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/multi.pyi:116: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/interval.pyi:256: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/interval.pyi:256: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/interval.pyi:295: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/interval.pyi:295: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/interval.pyi:301: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/interval.pyi:301: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:272: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/base.pyi:272: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:274: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/base.pyi:274: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:275: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/base.pyi:275: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:276: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/base.pyi:276: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:277: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/base.pyi:277: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:278: error: Unused "type: ignore" comment
+ pandas-stubs/core/indexes/base.pyi:278: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/arrays/datetimes.pyi:19: error: Unused "type: ignore" comment
+ pandas-stubs/core/arrays/datetimes.pyi:19: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/arrays/datetimelike.pyi:41: error: Unused "type: ignore" comment
+ pandas-stubs/core/arrays/datetimelike.pyi:41: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/interval.pyi:204: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/interval.pyi:204: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/interval.pyi:212: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/interval.pyi:212: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/tslibs/timestamps.pyi:217: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/tslibs/timestamps.pyi:217: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/tslibs/timestamps.pyi:225: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/tslibs/timestamps.pyi:225: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/tslibs/timedeltas.pyi:317: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/tslibs/timedeltas.pyi:317: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/tslibs/timedeltas.pyi:328: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/tslibs/timedeltas.pyi:328: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/tslibs/period.pyi:101: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/tslibs/period.pyi:101: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/_libs/tslibs/period.pyi:135: error: Unused "type: ignore" comment
+ pandas-stubs/_libs/tslibs/period.pyi:135: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_timefuncs.py:269: error: Unused "type: ignore" comment
+ tests/test_timefuncs.py:269: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_timefuncs.py:271: error: Unused "type: ignore" comment
+ tests/test_timefuncs.py:271: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_timefuncs.py:1106: error: Unused "type: ignore" comment
+ tests/test_timefuncs.py:1106: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_timefuncs.py:1107: error: Unused "type: ignore" comment
+ tests/test_timefuncs.py:1107: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_timefuncs.py:1108: error: Unused "type: ignore" comment
+ tests/test_timefuncs.py:1108: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:604: error: Unused "type: ignore" comment
+ tests/test_scalars.py:604: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:605: error: Unused "type: ignore" comment
+ tests/test_scalars.py:605: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:606: error: Unused "type: ignore" comment
+ tests/test_scalars.py:606: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:607: error: Unused "type: ignore" comment
+ tests/test_scalars.py:607: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:608: error: Unused "type: ignore" comment
+ tests/test_scalars.py:608: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:609: error: Unused "type: ignore" comment
+ tests/test_scalars.py:609: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:610: error: Unused "type: ignore" comment
+ tests/test_scalars.py:610: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:611: error: Unused "type: ignore" comment
+ tests/test_scalars.py:611: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:741: error: Unused "type: ignore" comment
+ tests/test_scalars.py:741: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:742: error: Unused "type: ignore" comment
+ tests/test_scalars.py:742: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:743: error: Unused "type: ignore" comment
+ tests/test_scalars.py:743: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:744: error: Unused "type: ignore" comment
+ tests/test_scalars.py:744: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:745: error: Unused "type: ignore" comment
+ tests/test_scalars.py:745: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:746: error: Unused "type: ignore" comment
+ tests/test_scalars.py:746: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:747: error: Unused "type: ignore" comment
+ tests/test_scalars.py:747: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:748: error: Unused "type: ignore" comment
+ tests/test_scalars.py:748: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:777: error: Unused "type: ignore" comment
+ tests/test_scalars.py:777: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_scalars.py:778: error: Unused "type: ignore" comment
+ tests/test_scalars.py:778: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:289: error: Unused "type: ignore" comment
+ tests/test_io.py:289: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:290: error: Unused "type: ignore" comment
+ tests/test_io.py:290: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:625: error: Unused "type: ignore" comment
+ tests/test_io.py:625: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:626: error: Unused "type: ignore" comment
+ tests/test_io.py:626: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:759: error: Unused "type: ignore" comment
+ tests/test_io.py:759: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:760: error: Unused "type: ignore" comment
+ tests/test_io.py:760: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_io.py:948: error: Unused "type: ignore" comment
+ tests/test_io.py:948: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_interval.py:56: error: Unused "type: ignore" comment
+ tests/test_interval.py:56: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_interval.py:58: error: Unused "type: ignore" comment

... (truncated 9 lines) ...

aioredis (https://github.com/aio-libs/aioredis)
- aioredis/connection.py:1201: error: Unused "type: ignore" comment
+ aioredis/connection.py:1201: error: Unused "type: ignore" comment  [unused-ignore]
- aioredis/connection.py:1205: error: Unused "type: ignore" comment
+ aioredis/connection.py:1205: error: Unused "type: ignore" comment  [unused-ignore]
- aioredis/client.py:94: error: Unused "type: ignore" comment
+ aioredis/client.py:94: error: Unused "type: ignore" comment  [unused-ignore]

isort (https://github.com/pycqa/isort)
- isort/deprecated/finders.py:22: error: Unused "type: ignore" comment
+ isort/deprecated/finders.py:22: error: Unused "type: ignore" comment  [unused-ignore]
- isort/deprecated/finders.py:28: error: Unused "type: ignore" comment
+ isort/deprecated/finders.py:28: error: Unused "type: ignore" comment  [unused-ignore]
- isort/setuptools_commands.py:7: error: Unused "type: ignore" comment
+ isort/setuptools_commands.py:7: error: Unused "type: ignore" comment  [unused-ignore]
- isort/setuptools_commands.py:13: error: Unused "type: ignore" comment
+ isort/setuptools_commands.py:13: error: Unused "type: ignore" comment  [unused-ignore]
- isort/pylama_isort.py:6: error: Unused "type: ignore" comment
+ isort/pylama_isort.py:6: error: Unused "type: ignore" comment  [unused-ignore]

vision (https://github.com/pytorch/vision)
- torchvision/prototype/transforms/_geometry.py:114: error: Unused "type: ignore" comment
+ torchvision/prototype/transforms/_geometry.py:114: error: Unused "type: ignore" comment  [unused-ignore]
- torchvision/prototype/transforms/_augment.py:43: error: Unused "type: ignore" comment
+ torchvision/prototype/transforms/_augment.py:43: error: Unused "type: ignore" comment  [unused-ignore]
- torchvision/prototype/transforms/_augment.py:54: error: Unused "type: ignore" comment
+ torchvision/prototype/transforms/_augment.py:54: error: Unused "type: ignore" comment  [unused-ignore]
- torchvision/prototype/transforms/_augment.py:65: error: Unused "type: ignore" comment
+ torchvision/prototype/transforms/_augment.py:65: error: Unused "type: ignore" comment  [unused-ignore]
- torchvision/prototype/transforms/_augment.py:98: error: Unused "type: ignore" comment
+ torchvision/prototype/transforms/_augment.py:98: error: Unused "type: ignore" comment  [unused-ignore]
- torchvision/prototype/transforms/_augment.py:254: error: Unused "type: ignore" comment
+ torchvision/prototype/transforms/_augment.py:254: error: Unused "type: ignore" comment  [unused-ignore]

aiohttp (https://github.com/aio-libs/aiohttp)
- aiohttp/connector.py:963: error: Unused "type: ignore" comment
+ aiohttp/connector.py:963: error: Unused "type: ignore" comment  [unused-ignore]
- aiohttp/client_reqrep.py:78: error: Unused "type: ignore" comment
+ aiohttp/client_reqrep.py:78: error: Unused "type: ignore" comment  [unused-ignore]

spark (https://github.com/apache/spark)
- python/pyspark/sql/types.py:148: error: Unused "type: ignore" comment
+ python/pyspark/sql/types.py:148: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/types.py:1636: error: Unused "type: ignore" comment
+ python/pyspark/sql/types.py:1636: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/types.py:1638: error: Unused "type: ignore" comment
+ python/pyspark/sql/types.py:1638: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/session.py:117: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ python/pyspark/sql/session.py:117: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment] code  [unused-ignore]
- python/pyspark/sql/observation.py:115: error: Unused "type: ignore" comment
+ python/pyspark/sql/observation.py:115: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/types.py:280: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/types.py:280: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/types.py:312: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/types.py:312: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/types.py:381: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/types.py:381: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/conversion.py:572: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/conversion.py:572: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/functions.pyi:56: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/functions.pyi:56: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/functions.pyi:58: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/functions.pyi:58: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/sql/pandas/functions.pyi:60: error: Unused "type: ignore" comment
+ python/pyspark/sql/pandas/functions.pyi:60: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/torch/distributor.py:759: error: Unused "type: ignore" comment
+ python/pyspark/ml/torch/distributor.py:759: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/torch/distributor.py:760: error: Unused "type: ignore" comment
+ python/pyspark/ml/torch/distributor.py:760: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/linalg/__init__.py:1620: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/__init__.py:1620: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/linalg/__init__.py:1629: error: Unused "type: ignore" comment
+ python/pyspark/mllib/linalg/__init__.py:1629: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/util.py:323: error: Unused "type: ignore" comment
+ python/pyspark/ml/util.py:323: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/util.py:662: error: Unused "type: ignore" comment
+ python/pyspark/ml/util.py:662: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/util.py:671: error: Unused "type: ignore" comment
+ python/pyspark/ml/util.py:671: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/functions.py:821: error: Unused "type: ignore" comment
+ python/pyspark/ml/functions.py:821: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/regression.py:120: error: Unused "type: ignore" comment
+ python/pyspark/mllib/regression.py:120: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/regression.py:126: error: Unused "type: ignore" comment
+ python/pyspark/mllib/regression.py:126: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/classification.py:76: error: Unused "type: ignore" comment
+ python/pyspark/mllib/classification.py:76: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/classification.py:217: error: Unused "type: ignore" comment
+ python/pyspark/mllib/classification.py:217: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/mllib/classification.py:225: error: Unused "type: ignore" comment
+ python/pyspark/mllib/classification.py:225: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/base.py:399: error: Unused "type: ignore" comment
+ python/pyspark/ml/base.py:399: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/wrapper.py:452: error: Unused "type: ignore" comment
+ python/pyspark/ml/wrapper.py:452: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:49: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:49: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:55: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:55: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:61: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:61: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:221: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:221: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:227: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:227: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:233: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:233: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:239: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:239: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/tree.py:245: error: Unused "type: ignore" comment
+ python/pyspark/ml/tree.py:245: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/recommendation.py:612: error: Unused "type: ignore" comment
+ python/pyspark/ml/recommendation.py:612: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/recommendation.py:618: error: Unused "type: ignore" comment
+ python/pyspark/ml/recommendation.py:618: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/recommendation.py:627: error: Unused "type: ignore" comment
+ python/pyspark/ml/recommendation.py:627: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/fpm.py:127: error: Unused "type: ignore" comment
+ python/pyspark/ml/fpm.py:127: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/fpm.py:137: error: Unused "type: ignore" comment
+ python/pyspark/ml/fpm.py:137: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:1222: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1222: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:1892: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1892: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:1900: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1900: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:1908: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:1908: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:2258: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2258: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:2473: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2473: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:2823: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2823: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:2831: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:2831: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:3332: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:3332: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:4010: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4010: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:4018: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4018: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:4462: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4462: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:4470: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4470: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:4835: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4835: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:4846: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:4846: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:5630: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:5630: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:5638: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:5638: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:6266: error: Unused "type: ignore" comment
+ python/pyspark/ml/feature.py:6266: error: Unused "type: ignore" comment  [unused-ignore]
- python/pyspark/ml/feature.py:6275: error: Unused "type: ignore" comment

... (truncated 423 lines) ...

kornia (https://github.com/kornia/kornia)
- kornia/grad_estimator/ste.py:39: error: Unused "type: ignore" comment
+ kornia/grad_estimator/ste.py:39: error: Unused "type: ignore" comment  [unused-ignore]
- kornia/grad_estimator/ste.py:48: error: Unused "type: ignore" comment
+ kornia/grad_estimator/ste.py:48: error: Unused "type: ignore" comment  [unused-ignore]
- kornia/augmentation/random_generator/base.py:85: error: Unused "type: ignore" comment
+ kornia/augmentation/random_generator/base.py:85: error: Unused "type: ignore" comment  [unused-ignore]
- kornia/augmentation/random_generator/base.py:91: error: Unused "type: ignore" comment

... (truncated 95 lines) ...```

@ilevkivskyi ilevkivskyi merged commit 61f6358 into python:master May 2, 2023
21 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-unused-ignores branch May 2, 2023 15:47
ilevkivskyi pushed a commit that referenced this pull request Jun 22, 2023
In #15164 we've made it so that `# type: ignore`s in lines skipped in
semantic analysis would not be flagged as unused.

In #15164 they were called "unreachable" lines but unreachability during
type-checking can result in the "Statement is unreachable" error, while
these statements are pruned before type-checking, so for clarity we'll
use the term "skipped".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot silence "unused 'type: ignore'" in version specific code
2 participants