-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Include JSON Schema input core schema in function schemas #11085
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 pydantic-docs with
|
| Latest commit: |
008f6d9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://190a7bc0.pydantic-docs.pages.dev |
| Branch Preview URL: | https://js-input-type-in-cs.pydantic-docs.pages.dev |
cb8e796 to
212a9c5
Compare
| @@ -280,12 +280,37 @@ def handle_dict_schema(self, schema: core_schema.DictSchema, f: Walk) -> core_sc | |||
| schema['values_schema'] = self.walk(values_schema, f) | |||
| return schema | |||
|
|
|||
| def handle_function_schema(self, schema: AnyFunctionSchema, f: Walk) -> core_schema.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.
This method was in reality never used: there's no 'function' core schema. Instead, a method for each type was created.
| schema['json_schema_input_schema'] = self.walk(schema['json_schema_input_schema'], f) | ||
| return schema | ||
|
|
||
| # TODO duplicate schema types for serializers and validators, needs to be deduplicated: |
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.
Will do in a follow up PR.
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.
Great. Can you open an issue just so we can track?
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.
| @@ -637,29 +637,6 @@ def walk(s, recurse): | |||
| } | |||
|
|
|||
|
|
|||
| def test_handle_function_schema(): | |||
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.
This test was added for coverage purposes, because as mentioned the method couldn't be called in "real" code
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.
Seems like a nice simplification, thanks for implementing this. Tells us, we shouldn't put core schemas in metadata.
I do think it's unfortunate that we have to store json schema related info on core schemas, but hey, they're coupled, so we might as well take advantage in v2.
| schema['json_schema_input_schema'] = self.walk(schema['json_schema_input_schema'], f) | ||
| return schema | ||
|
|
||
| # TODO duplicate schema types for serializers and validators, needs to be deduplicated: |
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.
Great. Can you open an issue just so we can track?
212a9c5 to
7e62daa
Compare
7e62daa to
de23974
Compare
CodSpeed Performance ReportMerging #11085 will not alter performanceComparing Summary
|
| @@ -229,13 +223,6 @@ def __get_pydantic_core_schema__(self, source_type: Any, handler: GetCoreSchemaH | |||
| serialization = None | |||
|
|
|||
| input_schema = handler.generate_schema(self.json_schema_input_type) | |||
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.
Note to self: although the default json_schema_input_type value is Any, we should also account for PydanticUndefined if explicitly set.
Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com>
Change Summary
Partly fixes #11033.
Requires pydantic/pydantic-core#1572
Related issue number
Checklist