Skip to content

Do not sort unused error codes in unused error codes warning#20036

Merged
JelleZijlstra merged 2 commits into
python:masterfrom
wyattscarpenter:uec
Oct 10, 2025
Merged

Do not sort unused error codes in unused error codes warning#20036
JelleZijlstra merged 2 commits into
python:masterfrom
wyattscarpenter:uec

Conversation

@wyattscarpenter

Copy link
Copy Markdown
Contributor

I intuit the previous author of this code sorted the codes for stability, but it actually should be in default order, to match what the user typed in. This will be more intuitive for the user.

In my first commit, I add the failing testUnusedIgnoreCodeOrder test. In my second commit, I fix the code.

@wyattscarpenter wyattscarpenter marked this pull request as ready for review October 9, 2025 10:59
@github-actions

github-actions Bot commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

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

scrapy (https://github.com/scrapy/scrapy)
- scrapy/squeues.py:28: error: Unused "type: ignore[misc, valid-type]" comment  [unused-ignore]
+ scrapy/squeues.py:28: error: Unused "type: ignore[valid-type, misc]" comment  [unused-ignore]
- scrapy/squeues.py:43: error: Unused "type: ignore[misc, valid-type]" comment  [unused-ignore]
+ scrapy/squeues.py:43: error: Unused "type: ignore[valid-type, misc]" comment  [unused-ignore]
- scrapy/squeues.py:77: error: Unused "type: ignore[misc, valid-type]" comment  [unused-ignore]
+ scrapy/squeues.py:77: error: Unused "type: ignore[valid-type, misc]" comment  [unused-ignore]
- scrapy/squeues.py:116: error: Unused "type: ignore[misc, valid-type]" comment  [unused-ignore]
+ scrapy/squeues.py:116: error: Unused "type: ignore[valid-type, misc]" comment  [unused-ignore]

setuptools (https://github.com/pypa/setuptools)
- setuptools/monkey.py:76: error: Unused "type: ignore[assignment, misc]" comment  [unused-ignore]
+ setuptools/monkey.py:76: error: Unused "type: ignore[misc, assignment]" comment  [unused-ignore]
- setuptools/monkey.py:85: error: Unused "type: ignore[assignment, misc]" comment  [unused-ignore]
+ setuptools/monkey.py:85: error: Unused "type: ignore[misc, assignment]" comment  [unused-ignore]
- setuptools/monkey.py:86: error: Unused "type: ignore[assignment, misc]" comment  [unused-ignore]
+ setuptools/monkey.py:86: error: Unused "type: ignore[misc, assignment]" comment  [unused-ignore]

pandas (https://github.com/pandas-dev/pandas)
- pandas/plotting/_matplotlib/hist.py:176: error: Unused "type: ignore[arg-type, index]" comment  [unused-ignore]
+ pandas/plotting/_matplotlib/hist.py:176: error: Unused "type: ignore[index, arg-type]" comment  [unused-ignore]

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/internal/ci_visibility/coverage.py:41: error: Unused "type: ignore[assignment, misc]" comment  [unused-ignore]
+ ddtrace/internal/ci_visibility/coverage.py:41: error: Unused "type: ignore[misc, assignment]" comment  [unused-ignore]

pandera (https://github.com/pandera-dev/pandera)
- pandera/backends/pandas/error_formatters.py:126: error: Unused "type: ignore[assignment, call-overload]" comment  [unused-ignore]
+ pandera/backends/pandas/error_formatters.py:126: error: Unused "type: ignore[call-overload, assignment]" comment  [unused-ignore]

poetry (https://github.com/python-poetry/poetry)
- tests/console/commands/self/test_remove_plugins.py:40: error: Unused "type: ignore[call-arg, index, union-attr]" comment  [unused-ignore]
+ tests/console/commands/self/test_remove_plugins.py:40: error: Unused "type: ignore[index, union-attr, call-arg]" comment  [unused-ignore]

xarray (https://github.com/pydata/xarray)
- xarray/computation/weighted.py:185: error: Unused "type: ignore[arg-type, call-arg]" comment  [unused-ignore]
+ xarray/computation/weighted.py:185: error: Unused "type: ignore[call-arg, arg-type]" comment  [unused-ignore]

@A5rocks

A5rocks commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator

I think your reconstruction of why it was sorted is correct based on this commit message: e883bba

@JelleZijlstra JelleZijlstra merged commit 5b7279b into python:master Oct 10, 2025
20 checks passed
@wyattscarpenter wyattscarpenter deleted the uec branch October 10, 2025 21:01
@makinde7788

Copy link
Copy Markdown

Nice improvement. Preserving the user's original ordering makes the output feel more predictable and avoids confusion when comparing with the source code. The failing clearly demonstrates the issue, and the fix aligns behavior with user expectatioms. This should also reduce noise in diffs and improve consistency for tools that depend on stable formatting.

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.

4 participants