-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Address case where model_construct on a class which defines model_post_init fails with AttributeError: __pydantic_private__ when subsequently model_copy'd #9168
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
Conversation
CodSpeed Performance ReportMerging #9168 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just requested some minor changes!
|
Made another push which uses a local |
|
Ah, I see. Let's go with your initial approach then (it feels a bit cleaner to me). I'll go ahead and approve - we can merge once you revert back to that approach. Thanks a bunch - looking forward to merging soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above -- approved, will merge when you revert back to your initial approach with the hasattr checks followed by the direct attribute accesses (thanks for pointing out, we already use that pattern in model_construct
|
Changes have been reverted to the hasattr() followed by direct attribute access, also reverting ALL changes in |
|
Please review and merge, or let me know if anything else is needed here. And, finally, THANKS for pydantic - a great solution to such a core problem :) |
|
Looks fantastic. Thank you for your contribution!! |
Change Summary
See detail as reported in Issue #9122
Note: this patch specifically addresses the handling of
__pydantic_private__in__copy__,__deepcopy__and__eq__. It does not address usage in several other places in main.py including:__{get,set,del}attr__,__{get,set}state__. It was unclear whether these were required, as eventually the model created bymodel_constructwill in fact have__pydantic_private__set (possibly toNone).:## Related issue number: #9122
Checklist
Please Review
Fix #9122
Selected Reviewer: @alexmojaki