Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
cloudflare-workers-and-pagesbot commentedDec 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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
to212a9c5
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
to7e62daa
Compare7e62daa
tode23974
Comparecodspeed-hqbot commentedDec 11, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
CodSpeed Performance ReportMerging#11085 willnot alter performanceComparing Summary
|
github-actionsbot commentedDec 11, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@@ -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 defaultjson_schema_input_type
value isAny
, we should also account forPydanticUndefined
if explicitly set.
Uh oh!
There was an error while loading.Please reload this page.
47ba4a5
intomainUh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Change Summary
Partlyfixes#11033.
Requirespydantic/pydantic-core#1572
Related issue number
Checklist