-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add support for instance method reassignment when extra='allow'
#7683
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
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 |
|
Please review Reviews welcome - not super set on a given pattern / if we should even do this, just looking for feedback 😄 |
…tch __getattr__ pattern
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
|
What happens if the model is also frozen? |
|
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). |
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