Track extra fields set after init in model_fields_set#12817
Merged
Viicos merged 2 commits intopydantic:mainfrom Mar 5, 2026
Merged
Track extra fields set after init in model_fields_set#12817Viicos merged 2 commits intopydantic:mainfrom
model_fields_set#12817Viicos merged 2 commits intopydantic:mainfrom
Conversation
Merging this PR will improve performance by 9.58%
Performance Changes
Comparing |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Contributor
Author
|
please review |
Viicos
reviewed
Mar 5, 2026
Viicos
requested changes
Mar 5, 2026
model_fields_set
When setting an extra field after model initialization, the field was added to model_extra but not to model_fields_set. This was inconsistent with regular fields which are tracked in model_fields_set when set after init. Updated both the inline extra field assignment and the extra_known setattr handler to also update __pydantic_fields_set__. Closes pydantic#11134
49ff7bc to
6ac5ac6
Compare
Viicos
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Summary
Fix
_setattr_handlerto update__pydantic_fields_set__when setting extra fields after init.Related issue number
fix #11134
Checklist
Selected Reviewer: @Viicos