Do not sort unused error codes in unused error codes warning#20036
Merged
Conversation
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
approved these changes
Oct 10, 2025
Collaborator
|
I think your reconstruction of why it was sorted is correct based on this commit message: e883bba |
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.