KEMBAR78
Fix `dmypy suggest` interaction with `__new__` by sterliakov · Pull Request #18966 · python/mypy · GitHub
Skip to content

Conversation

sterliakov
Copy link
Collaborator

Fixes #18964. __new__ is special - it has is_static set in semanal.py, but still has first cls argument. This PR tells dmypy suggest about that.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

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

This makes sense, is this pattern elsewhere and if so would it make sense to extract it to an @property? (I guess people wouldn't know to use it.)

@sterliakov
Copy link
Collaborator Author

Turns out there are a few places doing such check, so reusing sounds reasonable. Added a doc comment for the attribute with usage guidance.

@github-actions

This comment has been minimized.

@sterliakov
Copy link
Collaborator Author

@JukkaL if you're preparing the next release, can this PR sneak in? It only fixes a crash in dmypy suggest and shouldn't affect anything else

@hauntsaninja hauntsaninja force-pushed the bugfix/gh-18964-dmypy-suggest-dunder-new branch from 52dedc3 to dcbb0d2 Compare June 18, 2025 18:19
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja merged commit ae778cc into python:master Jun 18, 2025
19 checks passed
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.

dmypy suggest crashes on __new__ with IndexError

3 participants