Skip to content

Fix crash on redefined class variable annotated with Final[<type>] #12951

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

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jun 7, 2022

Description

Fixes #12950.

Mypy currently crashes on this snippet of code:

from typing import Final

class MyClass:
    a: None
    a: Final[int] = 1

This PR fixes that.

Test Plan

I added a test.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2022

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

@JelleZijlstra JelleZijlstra merged commit c3e32e3 into python:master Jun 7, 2022
@AlexWaygood AlexWaygood deleted the final branch June 7, 2022 17:24
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.

mypy fails when redefining class variable with Final[Type] type annotation
2 participants