Skip to content
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

Ensure instances of CallableType can always be hashed #12741

Merged
merged 1 commit into from
May 8, 2022

Conversation

AlexWaygood
Copy link
Member

Description

Trying to hash an instance of mypy.types.CallableType will crash if self.fallback.type is a FakeInfo. Apparently this is the case if the CallableType represents a classmethod alternative constructor on a TypedDict. Such alternative-constructor methods aren't currently supported by mypy, but mypy also shouldn't crash if it comes across them.

Fixes #5653 (though I'm not 100% sure if this is the best solution).

Test Plan

Test case added to check-typeddict.test.

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Not sure this is the greatest solution either, but it works and fixes the crash.

@JelleZijlstra JelleZijlstra merged commit 49d5cc9 into python:master May 8, 2022
@AlexWaygood AlexWaygood deleted the typeddict-crash branch May 8, 2022 05:08
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.

Crash on definition of TypedDict method
2 participants