Add support for instance method reassignment when extra='allow'#7683
Merged
sydney-runkle merged 7 commits intomainfrom Oct 2, 2023
Merged
Add support for instance method reassignment when extra='allow'#7683sydney-runkle merged 7 commits intomainfrom
extra='allow'#7683sydney-runkle merged 7 commits intomainfrom
Conversation
Deploying with
|
| Latest commit: |
46db5a7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://52b63d03.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://fix-setattr-with-extra-setti.pydantic-docs2.pages.dev |
Contributor
Author
|
Please review Reviews welcome - not super set on a given pattern / if we should even do this, just looking for feedback 😄 |
…tch __getattr__ pattern
dmontagu
reviewed
Sep 29, 2023
dmontagu
approved these changes
Sep 29, 2023
dmontagu
reviewed
Sep 29, 2023
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Member
|
What happens if the model is also frozen? |
Contributor
|
Lol good question. I checked, and:
I think this is reasonable behavior for frozen models (i.e., frozen instances don't let you overwrite any attributes, not just fields/extra/etc.). And since it raises an error, if we did ever want to change this in the future it would be easier to justify in terms of backwards compatibility than going in the other direction (i.e., making a non-error into an error). |
adriangb
approved these changes
Oct 2, 2023
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
Adding aligning the logic of
__setattr__and__getattr__whenextra=Trueon a model's config.Related issue number
Fix #7631
Checklist
Selected Reviewer: @Kludex