FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Narrowing for comparisons against x.__class__ by hauntsaninja · Pull Request #20642 · python/mypy · GitHub

Repository navigation

Narrowing for comparisons against x.__class__ - #20642

Merged
JukkaL merged 1 commit into
python:masterfrom
hauntsaninja:narrow21
Jan 26, 2026
Merged

JukkaL merged 1 commit into
python:masterfrom
hauntsaninja:narrow21

Conversation

Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
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]

Copy link
Copy Markdown
Collaborator Author

The black case is covered by a test from #20603


def bar(y: Any):
if y.__class__ == int:
reveal_type(y) # N: Revealed type is "Any"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this Any will actually get fixed by #20643

JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm glad to see so many type ignores fixed! Thanks!

JukkaL merged commit 1288f20 into python:master Jan 26, 2026
23 checks passed
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL