KEMBAR78
Fix swapped errors for frozen/non-frozen dataclass inheritance by nawrazi · Pull Request #18918 · python/mypy · GitHub
Skip to content

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
@github-actions

This comment has been minimized.

@brianschubert
Copy link
Member

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.

@github-actions
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