-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Only mark model as complete once all fields are complete #11759
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
Hmm, we're good on Python 3.11+, but failing on earlier versions... The issue appears to be that inside This causes Pydantic to leave the pydantic/pydantic/_internal/_fields.py Lines 211 to 213 in 625dd42
Pydantic behaves correctly because Interestingly, pydantic/pydantic/_internal/_typing_extra.py Lines 274 to 289 in 625dd42
For this PR, I'll change it from @Viicos What do you think? |
CodSpeed Performance ReportMerging #11759 will not alter performanceComparing Summary
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
@Viicos Please review! |
This is a bug that was fixed in python/cpython#30900. iirc, this unfortunately can't be backported to
I think we can live with the inconsistency here. The primary goal of |
0c9ec0f
to
dd5f919
Compare
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.
Otherwise looks good
@Viicos Back to you! |
The failing Pandera test is already being fixed in #11767. |
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
03eebf1
to
ed18a83
Compare
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.
Thanks @DouweM
Change Summary
BaseModel.model_rebuild
already ensured that__pydantic_fields_complete__
wasTrue
before marking the model as complete, including rebuilding model fields to 1) see if any unknown annotations could not be resolved, and 2) if not, to make sure that the mock error message includes the name of the unknown annotation.We now do the same on
ModelMetaclass.__new__
, to make sure that subclasses of incomplete superclasses don't incorrectly get marked as complete.Here is such an example:
Related issue number
Preparation for #11453
Checklist
Selected Reviewer: @sydney-runkle