Skip to content
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

Fix "not callable" issue for @dataclass(frozen=True) with Final attr #18572

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

sobolevn
Copy link
Member

Closes #18567

We should allow inferenced a: Final = 1

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm what about changing _freeze in mypy.plugins.dataclasses to skip final attributes? Does it turn final attributes into properties? If yes, this sounds wrong to me.

Can you also test what happens if you access a final attribute via the type object, e.g. My.a?

@sobolevn
Copy link
Member Author

sobolevn commented Feb 3, 2025

Does it turn final attributes into properties? If yes, this sounds wrong to me.

Yes, it does. I will check what can be done there!

@sobolevn
Copy link
Member Author

sobolevn commented Feb 5, 2025

@JukkaL you were right, frozen plugin fix is better. Thank you!

Copy link
Contributor

github-actions bot commented Feb 5, 2025

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

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good.

@JukkaL JukkaL merged commit ac921ae into master Feb 5, 2025
18 checks passed
@JukkaL JukkaL deleted the issue-18567 branch February 5, 2025 13:56
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.

dataclass(frozen=True) not working with default Final qualifier
2 participants