Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.3k
Inline references if possible when generating schema forjson_schema_input_type#10439
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
codspeed-hqbot commentedSep 18, 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#10439 willdegrade performances by 12.42%Comparing Summary
Benchmarks breakdown
|
github-actionsbot commentedSep 18, 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.
Coverage reportClick to see where and how coverage changed
This report was generated bypython-coverage-comment-action | ||||||||||||||||||||||||
sydney-runkle left a comment
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 work. Thanks for the nice tests here!
Uh oh!
There was an error while loading.Please reload this page.
cloudflare-workers-and-pagesbot commentedSep 18, 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: | 8f3c4b6 |
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c2e1881d.pydantic-docs.pages.dev |
| Branch Preview URL: | https://10434.pydantic-docs.pages.dev |

Uh oh!
There was an error while loading.Please reload this page.
Fixes#10434.
Requires#10444.
Previously, the core schema for:
{│'type':'model',│'cls':<class'__main__.Model'>,│'schema': {│ │'type':'model-fields',│ │'fields': {│ │ │'sub': {│ │ │ │'type':'model-field',│ │ │ │'schema': {│ │ │ │ │'type':'function-plain',│ │ │ │ │'function': {'type':'no-info','function':<functionModel.<lambda>at0x7bd0081e94e0>},│ │ │ │ │'metadata': {│ │ │ │ │ │'pydantic_js_functions': [],│ │ │ │ │ │'pydantic_js_annotation_functions': [],│ │ │ │ │ │'pydantic_js_input_core_schema': {'type':'definition-ref','schema_ref':'__main__.Sub:97821927158416'}│ │ │ │ │ },│ │ │ │ │'serialization': {...}│ │ │ │ },│ │ │ │'metadata': {...}│ │ │ }│ │ },│ │'model_name':'Model',│ │'computed_fields': []│ },│'custom_init':False,│'root_model':False,│'config': {'title':'Model'},│'ref':'__main__.Model:97821929019248',│'metadata': {...}}With
pydantic_js_input_core_schemaholding a reference to__main__.Sub:97821927158416that would not be present in the core schema (because for a plain validator, the source type is not relevant), JSON Schema generation naturally fails (and thankfully only for JSON Schema generation, as thispydantic_js_input_core_schemametadata field is only relevant for JSON Schemas).My first idea was to add extra logic in the
_WalkCoreSchemaclass to handle this metadata field and include it in schema walking, but this is truly not ideal as we are leaking JSON Schema related logic inside this class (kind of a consequence of our metadata handling which wasn't ideal in the first place, as discussed already :/).So I decided we should inline refs in the validator class directly, in a safe way for recursive references.
Checklist