Skip to content

Fix dmypy suggest interaction with __new__ #18966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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.

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.

Copy link
Contributor

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

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
2 participants