-
Notifications
You must be signed in to change notification settings - Fork 292
Use return_schema for computed fields #595
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
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #595 +/- ##
==========================================
+ Coverage 94.19% 94.21% +0.01%
==========================================
Files 96 96
Lines 13099 13114 +15
Branches 24 24
==========================================
+ Hits 12339 12355 +16
+ Misses 754 753 -1
Partials 6 6
Continue to review full report in Codecov by Sentry.
|
CodSpeed Performance ReportMerging #595 Summary
|
please review |
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.
LGTM.
My only suggested would be that we should replace all json_return_type
usage with this.
please update - just to reassign, feel free to merge, or do more here. |
I'll note that those are only present in I think given that relates to |
@@ -415,23 +415,25 @@ def model_ser_schema(cls: Type[Any], schema: CoreSchema) -> ModelSerSchema: | |||
class ComputedField(TypedDict, total=False): | |||
type: Required[Literal['computed-field']] | |||
property_name: Required[str] | |||
json_return_type: JsonReturnTypes | |||
return_schema: Required[CoreSchema] |
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 we need to change Pydantic to generate this from a return type annotation (which we'll require)?
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.
yes, see pydantic/pydantic#5708
This change provides a way to specify a serialization schema for computed fields (previously, they were treated as Any, which would lead to the FastAPI security problem in pydantic). This is also useful for generating JSON schemas for computed fields.
The pydantic-side PR is pydantic/pydantic#5708 (note that that PR depends on pydantic/pydantic#5707, which did not require changes to pydantic-core).
Selected Reviewer: @samuelcolvin