-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow config and bases to be specified together in create_model()
#11714
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
PR Change SummaryAllowed configuration and base classes to be specified together in the
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
Deploying pydantic-docs with
|
Latest commit: |
7a702a7
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5cf8e1f1.pydantic-docs.pages.dev |
Branch Preview URL: | https://create-model-config-base.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #11714 will not alter performanceComparing Summary
|
46d0e9e
to
7a702a7
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
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.
I assume that the original limitation was added because inheritance from a base class will set config. How does that config merge with the explicitly set config? Is that where confusion may occur? (e.g. can this do weird things like make the parent model fields all strict?)
It will be equivalent to the following, as shown in the added test: class Base(BaseModel):
a: str
model_config = {'str_to_lower': True}
class Model(Base):
model_config = {'str_max_length': 3} Which will result in
as in "normal" subclassing, this shouldn't be the case. |
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.
Ah ok, that justification makes sense to me. LGTM with just one question.
The limitation was added back in the early days of Pydantic, when `create_model()` was implemented. It is no longer necessary. Backport of: #11714
Change Summary
Fixes #2137.
Related issue number
Checklist