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: avoid multiple calls of __post_init__ when dataclasses are inherited #4493

Merged

Conversation

PrettyWood
Copy link
Member

When __post_init__ was defined on a parent class, new_post_init would be called many times because it "auto-refers" itself (it refers the parent one).
Now we call the right __post_init__

fix #4487

@PrettyWood
Copy link
Member Author

Please review

Copy link
Member

@hramezani hramezani left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

LGTM, @PrettyWood feel free to merge or add other fixes.

@samuelcolvin
Copy link
Member

@PrettyWood what do you think? Should we merge this and make a release, or do you want to have a shot at the other dataclass issues?

@PrettyWood
Copy link
Member Author

I'll check this weekend. Can't before. Way too much on my plate sorry

@samuelcolvin
Copy link
Member

That's very kind, thank you. No problem about the delay.

@samuelcolvin samuelcolvin mentioned this pull request Sep 22, 2022
8 tasks
@PrettyWood PrettyWood linked an issue Dec 27, 2022 that may be closed by this pull request
16 tasks
@PrettyWood PrettyWood merged commit a825106 into pydantic:1.10.X-fixes Dec 29, 2022
@PrettyWood PrettyWood deleted the fix-dataclasses-post-init-calls branch December 29, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dataclass post_init_post_parse called multiple times.
3 participants