Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: error for Final fields with init=False (#13119)#20382

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Benitex wants to merge2 commits intopython:master
base:master
Choose a base branch
Loading
fromBenitex:metaclass-late-final-field

Conversation

@Benitex
Copy link

This Pull Request adds an error report when a dataclass field is declared asFinal, hasinit=False, and lacks a default value, as discussed in Issue#13119. This change adds a check to detect this combination while avoiding complex control flow analysis, as requested. It also flags no error if there's a__post_init__ method, to avoid possible false positives.

Test cases were adapted from PR#14285. I also added a new test case for default values provided on the field declaration.
Thanks to@jakezych for the original test cases.

Fixes#13119

Benitexand others added2 commitsDecember 8, 2025 18:32
Test cases from PRpython#14285, thanks to@jakezych.Co-Authored-By: Jake Zych <56098501+jakezych@users.noreply.github.com>Co-Authored-By: Rafael Christof <rafaeldana@danatelecom.com>
@github-actions
Copy link
Contributor

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

no error when settinginit=False onFinal field in dataclass

1 participant

@Benitex

[8]ページ先頭

©2009-2025 Movatter.jp