Skip to content

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