E520 Keep values of private attributes set within `model_post_init` in subclasses by alexmojaki · Pull Request #7775 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@alexmojaki
Copy link
Contributor
@alexmojaki alexmojaki commented Oct 9, 2023

Change Summary

Check for an existing __pydantic_private__ dict in init_private_attributes and account for values within, rather than always replacing with a new dict.

Related issue number

Fixes #7091

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

@alexmojaki
Copy link
Contributor Author

please review

@sydney-runkle
Copy link
Contributor

@alexmojaki,

Thanks so much for your contribution! Could you take a look at this comment when you have a chance?

Copy link
Contributor
@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

Looks good otherwise 👍 just a small change request

@pydantic-hooky pydantic-hooky bot added awaiting author revision awaiting changes from the PR author and removed ready for review labels Oct 11, 2023
@pydantic-hooky pydantic-hooky bot assigned alexmojaki and unassigned sydney-runkle Oct 11, 2023
@sydney-runkle
Copy link
Contributor

@dmontagu did you have a test change you wanted to add?

Copy link
Contributor
@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

LGTM, thanks so much for this contribution 🌟.

@sydney-runkle sydney-runkle removed the awaiting author revision awaiting changes from the PR author label Oct 11, 2023
@sydney-runkle
Copy link
Contributor

Note to myself, when I work on the #7656 task, I want to add a more robust test for this behavior.

@sydney-runkle sydney-runkle merged commit 218b5ad into pydantic:main Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inheritance of Models with private attributes causes unexpected behavior via model_post_init

2 participants

0