-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Dataclasses derived from empty frozen bases skip immutability checks #87342
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
Comments
Dataclasses derived from empty frozen bases skip immutability checks. Repro snippet:
Usecase: sometimes developers define an empty frozen base dataclass with detailed docs and require other dataclasses to inherit from it as a code contract to avoid accidental in-place modifications. Affects all versions of Python that support dataclasses (including the backport for py3.6). |
Thanks! |
Wether the original behaviour was intentional or not this change introduces backwards incompatibility (and in our case, breakage) between 3.8.10 and previous releases (I expect the same to be true for the equivalent 3.9 releases). |
Can you provide a small snippet of code showing the kind of thing that broke? |
@eric.smith Sure, here you go: dataclass_empty.py:
Running this on < 3.8.10:
And on 3.8.10:
|
Hmm. I think maybe the intent was that if you're frozen, treat all the fields as frozen, including ones you inherit, regardless if the base classes are frozen or not. |
I think this was fixed with #109437, so I'm going to close this one. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: