KEMBAR78
Ensure instances of `CallableType` can always be hashed by AlexWaygood · Pull Request #12741 · python/mypy · GitHub
Skip to content

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