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

Replace hard crash with typecheck error when subclass method has the same name as type alias #13015

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

wesleywright
Copy link
Collaborator

Description

Fixes #5425.

Typechecking for method overrides ended in an assert False for any AST nodes other than FuncDef, OverloadedFuncDef, Decorator, and Var. This PR replaces this with a typecheck error for any unrecognized AST nodes instead.

Test Plan

Added a new test case to check-classes.test covering the original bug report from the example, as well as some extra cases that Jukka mentioned in the comments.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, can we use UninhabitedType instead of NoneType?

@github-actions
Copy link
Contributor

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

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 24, 2022

Thanks, can we use UninhabitedType instead of NoneType?

Since we used NoneType previously in the same function, this seem fine to me. We don't actually seem to perform any interesting type operations on the type, unless it's a function type.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me.

@JukkaL JukkaL merged commit 203bd64 into python:master Jun 24, 2022
Gobot1234 pushed a commit to Gobot1234/mypy that referenced this pull request Aug 12, 2022
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.

Overriding definition such as type alias in a subclass causes a crash
3 participants