Skip to content

Fix crash on bare Final in dataclass #13528

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
Aug 27, 2022

Conversation

ilevkivskyi
Copy link
Member

Fixes #10090

Unfortunately we cannot fully support this use case. Mypy requires explicit type annotations to generate methods for dataclasses before type checking. While type inference for bare Final happens during type checking. I still try to infer type if the default is a literal, otherwise give an error, and use Any for generated methods.

cc @AlexWaygood @JukkaL

@github-actions
Copy link
Contributor

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

@ilevkivskyi
Copy link
Member Author

This is quite trivial so I will just merge it. (Details of this corner case can be changed later if needed.)

@ilevkivskyi ilevkivskyi merged commit a9bc366 into python:master Aug 27, 2022
@ilevkivskyi ilevkivskyi deleted the fix-dataclass-final branch August 27, 2022 00:19
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.

Several dataclass crashes involving Final attributes
1 participant