Narrowing for comparisons against x.__class__#20642
Merged
JukkaL merged 1 commit intopython:masterfrom Jan 26, 2026
Merged
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: beartype (https://github.com/beartype/beartype)
+ beartype/_util/hint/pep/utilpepsign.py:592: error: Unused "type: ignore" comment [unused-ignore]
black (https://github.com/psf/black)
+ src/blib2to3/pytree.py:84:9: error: Returning Any from function declared to return "bool" [no-any-return]
static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/util.py:2085: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/util.py:2087: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/util.py:2089: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/util.py:2095: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/util.py:2096: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/util.py:2186: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/util.py:2188: error: Unused "type: ignore" comment [unused-ignore]
- static_frame/core/util.py:2307: error: "Hashable" has no attribute "start" [attr-defined]
- static_frame/core/util.py:2307: note: Error code "attr-defined" not covered by "type: ignore" comment
- static_frame/core/util.py:2309: error: "Hashable" has no attribute "stop" [attr-defined]
- static_frame/core/util.py:2309: note: Error code "attr-defined" not covered by "type: ignore" comment
- static_frame/core/util.py:2310: error: "Hashable" has no attribute "stop" [attr-defined]
- static_frame/core/util.py:2310: note: Error code "attr-defined" not covered by "type: ignore" comment
- static_frame/core/util.py:2311: error: "Hashable" has no attribute "step" [attr-defined]
- static_frame/core/util.py:2311: note: Error code "attr-defined" not covered by "type: ignore" comment
- static_frame/core/util.py:2312: error: "Hashable" has no attribute "step" [attr-defined]
- static_frame/core/util.py:2312: note: Error code "attr-defined" not covered by "type: ignore" comment
+ static_frame/core/loc_map.py:157: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/loc_map.py:169: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/loc_map.py:171: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/loc_map.py:174: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/loc_map.py:176: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/loc_map.py:177: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/node_fill_value.py:126: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/container_util.py:1065: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/container_util.py:1526: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/container_util.py:1528: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/container_util.py:1541: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:491: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:492: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:2368: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3343: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3347: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3348: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3351: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3352: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3356: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3358: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3361: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/type_blocks.py:3366: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:228: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:231: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:332: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:419: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:458: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:459: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:482: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:1031: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:1088: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index.py:1899: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index_hierarchy.py:492: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index_hierarchy.py:494: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index_hierarchy.py:567: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index_hierarchy.py:2177: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/index_auto.py:85: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/archive_npy.py:232: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series.py:634: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series.py:636: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series.py:639: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series.py:642: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/series.py:645: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/frame.py:1304: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/frame.py:1441: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/frame.py:3491: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/frame.py:3494: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/frame.py:3497: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/frame.py:3499: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/bus.py:524: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/bus.py:526: error: Unused "type: ignore" comment [unused-ignore]
+ static_frame/core/bus.py:528: error: Unused "type: ignore" comment [unused-ignore]
|
Collaborator
Author
|
The black case is covered by a test from #20603 |
hauntsaninja
commented
Jan 24, 2026
|
|
||
| def bar(y: Any): | ||
| if y.__class__ == int: | ||
| reveal_type(y) # N: Revealed type is "Any" |
Collaborator
Author
There was a problem hiding this comment.
I think this Any will actually get fixed by #20643
JukkaL
approved these changes
Jan 26, 2026
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
I'm glad to see so many type ignores fixed! Thanks!
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.
No description provided.