Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
sydney-runkle merged 3 commits intomainfromjs-input-type-in-cs
Dec 18, 2024

Conversation

Viicos
Copy link
Member

@ViicosViicos commentedDec 10, 2024
edited
Loading

Change Summary

Partlyfixes#11033.
Requirespydantic/pydantic-core#1572

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

emaheuxPEREN reacted with hooray emoji
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelDec 10, 2024
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedDec 10, 2024
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

@@ -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:
Copy link
MemberAuthor

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:
Copy link
MemberAuthor

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.

Copy link
Contributor

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?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

sydney-runkle reacted with thumbs up emoji
@@ -637,29 +637,6 @@ def walk(s, recurse):
}


def test_handle_function_schema():
Copy link
MemberAuthor

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

Copy link
Contributor

@sydney-runklesydney-runkle left a 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:
Copy link
Contributor

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?

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedDec 11, 2024
edited
Loading

CodSpeed Performance Report

Merging#11085 willnot alter performance

Comparingjs-input-type-in-cs (008f6d9) withmain (d8b610c)

Summary

✅ 46 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedDec 11, 2024
edited
Loading

Coverage report

This PR does not seem to contain any modification to coverable code.

@@ -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)
Copy link
MemberAuthor

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.

@sydney-runklesydney-runkleenabled auto-merge (squash)December 18, 2024 14:18
@sydney-runklesydney-runkle merged commit47ba4a5 intomainDec 18, 2024
52 checks passed
@sydney-runklesydney-runkle deleted the js-input-type-in-cs branchDecember 18, 2024 14:20
Viicos added a commit that referenced this pull requestDec 18, 2024
Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees
No one assigned
Labels
relnotes-fixUsed for bugfixes.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

JSON Schema gen chokes onBeforeValidator with a union in thejson_schema_input_type
2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp