-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Support defer_build
for Pydantic dataclasses
#10313
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
Also return early if `defer_build` is set for Pydantic models.
Deploying pydantic-docs with
|
Latest commit: |
7ae6da8
|
Status: | ✅ Deploy successful! |
Preview URL: | https://c4413a6e.pydantic-docs.pages.dev |
Branch Preview URL: | https://dc-defer-build.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #10313 will not alter performanceComparing Summary
|
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.
Looks great, left one comment re the _force_build
argument - would like to avoid that if possible.
I've submitted #10329, which we can probably merge + rebase with to make this PR just a bit more simple.
So the reason why the added pydantic/pydantic/_internal/_dataclasses.py Line 146 in 59a3de7
So that the following works as expected: @pydantic_dataclass(config={'strict': True})
class DC:
a: int
assert DC.__pydantic_config__ == {'strict': True} If in pydantic/pydantic/dataclasses.py Lines 338 to 345 in c2a325b
The following will happen: @pydantic_dataclass
class DC:
__pydantic_config__ = {'defer_build': True} # or as a decorator parameter, doesn't matter
assert DC.__pydantic_config__ == {'defer_build': True}
rebuild_dataclass(DC)
assert DC.__pydantic_config__ == {'defer_build': True} # AssertionError, `'defer_build'` is now set to `False` And is inconsistent with the |
I see, makes sense. Let's revert back then to use the |
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.
Nice work!
defer_build
for Pydantic dataclassesdefer_build
for Pydantic dataclasses
Also return early if
defer_build
is set for Pydantic models.Change Summary
Related issue number
Checklist