Skip to content

Fix swapped errors for frozen/non-frozen dataclass inheritance #18918

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 2 commits into from
Apr 14, 2025

Conversation

nawrazi
Copy link
Contributor

@nawrazi nawrazi commented Apr 13, 2025

There is a mix-up in error messages related to frozen and non-frozen dataclass inheritance.

Currently:

  • Inheriting a frozen dataclass from a non-frozen one incorrectly gives the error:
    Cannot inherit non-frozen dataclass from a frozen one

  • Inheriting a non-frozen dataclass from a frozen one gives the error:
    Cannot inherit frozen dataclass from a non-frozen one

This PR swaps these two error messages and rephrases them for better clarity.

@nawrazi nawrazi changed the title Fix swapped error messages for frozen/non-frozen dataclass inheritance Fix swapped errors for frozen/non-frozen dataclass inheritance Apr 13, 2025

This comment has been minimized.

@brianschubert
Copy link
Collaborator

Thanks for the PR!

I think the current phrasing is a bit confusing. I'd suggest rewording these as Frozen dataclass cannot inherit from a non-frozen dataclass and vice versa.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

Nice fix, thank you!

@hauntsaninja hauntsaninja merged commit a3ce6d5 into python:master Apr 14, 2025
18 checks passed
@nawrazi nawrazi deleted the frozen-inheritence branch April 14, 2025 22:58
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.

3 participants