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

Fix serialization schema generation when usingPlainValidator#10427

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 intomainfrom10385
Sep 17, 2024

Conversation

Viicos
Copy link
Member

@ViicosViicos commentedSep 17, 2024
edited
Loading

Do not hardcode a new wrap serializer schema if a serialization schema was already generated before.

Note that the following can be used as a failing MRE, related to the TODO comment:

fromtypingimportAnnotatedfrompydanticimportBaseModel,PlainValidatorfrompydantic_coreimportcore_schemaclassMyDict:@classmethoddef__get_pydantic_core_schema__(cls,source,handler):returncore_schema.dict_schema(keys_schema=handler.generate_schema(str),values_schema=handler.generate_schema(int),serialization=core_schema.filter_dict_schema(include={'a'},            ),        )classModel(BaseModel):f:Annotated[MyDict,PlainValidator(val)]# If core schema validation is disabled:Model(f={'a':1,'b':1}).model_dump()#> {'f': {'a': 1, 'b': 1}}# Should be: {'f': {'a': 1}}

Maybe we should create a new issue, and add axfail test linking to this issue?

Related issue number

Fixes#10385
Fixes#8586

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

sydney-runkle reacted with thumbs up emoji
Do not hardcode a new wrap serializer schema if a serializationschema was already generated before.
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedSep 17, 2024
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:1fb016f
Status: ✅  Deploy successful!
Preview URL:https://956db31c.pydantic-docs.pages.dev
Branch Preview URL:https://10385.pydantic-docs.pages.dev

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedSep 17, 2024
edited
Loading

CodSpeed Performance Report

Merging#10427 willnot alter performance

Comparing10385 (1fb016f) withmain (cf671c8)

Summary

✅ 49 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedSep 17, 2024
edited
Loading

Coverage report

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

core_schema.wrap_serializer_function_ser_schema(
function=lambda v, h: h(v),
schema=schema,
return_schema=schema,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not need to dohandler.generate_schema(source_type) here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Hum I don't think it will change anything in this case asschema is guaranteed to not have any serialization key here, but I'll change to align with how it is done inPlain/WrapSerializer.

sydney-runkle reacted with thumbs up emoji
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.

Wonderful, thanks@Viicos!!

@sydney-runklesydney-runkleenabled auto-merge (squash)September 17, 2024 14:21
@sydney-runklesydney-runkle merged commit00b3762 intomainSep 17, 2024
59 checks passed
@sydney-runklesydney-runkle deleted the 10385 branchSeptember 17, 2024 14:24
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
2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp