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

Consolidate schema definitions logic in the_Definitions class#11208

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
Viicos merged 2 commits intomainfromdefinitions-improvements
Jan 7, 2025

Conversation

Viicos
Copy link
Member

Some common patterns are defined as methods to avoid duplication (e.g.create_reference_to_schema, used to store a schema as a definition and returns a'definition-reference' schema). A couple existing methods on theGenerateSchema class are moved (and renamed to better describe what they do) to the_Definitions class.

Proper docstrings are added to attribute and methods.

Type hints are tweaked when necessary.

This is meant to be a simplified changeset of#10887, only with the necessary changes present.

Change Summary

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

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelJan 2, 2025
@ViicosViicosforce-pushed thedefinitions-improvements branch fromfcd4818 to5de851fCompareJanuary 2, 2025 22:17
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedJan 2, 2025
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:c388c19
Status: ✅  Deploy successful!
Preview URL:https://506c3228.pydantic-docs.pages.dev
Branch Preview URL:https://definitions-improvements.pydantic-docs.pages.dev

View logs

self.seen: set[str] = set()
self.definitions: dict[str, core_schema.CoreSchema] = {}
self._recursively_seen = set()
self._definitions = {}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@MarkusSintonen, in your PR, you made a distinction between definitions stored fromcreate_reference_to_schema and definitions coming fromunpack_definitions (in your PR, as_unpacked_definitions), i.e. definitions potentially coming from the cached attribute of Pydantic models.

What was the reason to do so?

sydney-runkle reacted with eyes emoji
@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedJan 2, 2025
edited
Loading

CodSpeed Performance Report

Merging#11208 willnot alter performance

Comparingdefinitions-improvements (c388c19) withmain (da0449e)

Summary

✅ 46 untouched benchmarks

Comment on lines 827 to 829
# if schema['type'] == 'definition-ref':
# return core_schema.definition_reference_schema(schema_ref=schema['schema_ref'])
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@MarkusSintonen, this is an addition in your PR. Seems like test passes without it. Do you remember why this might be required? I'm assuming this is part of#10655, where'definition-ref' schemas are inlined in place, and thus this might some kind of safety copy?

sydney-runkle reacted with eyes emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm removing it from this PR, as if it needs to be included, this will be in the schema walking refactor PR.

sydney-runkle reacted with thumbs up emoji
@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedJan 2, 2025
edited
Loading

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _generate_schema.py2121-2123
  _schema_generation_shared.py
Project Total 

This report was generated bypython-coverage-comment-action

@ViicosViicosforce-pushed thedefinitions-improvements branch from5de851f toe3a19ebCompareJanuary 7, 2025 14:59
@ViicosViicos marked this pull request as ready for reviewJanuary 7, 2025 14:59
@ViicosViicosforce-pushed thedefinitions-improvements branch frome3a19eb tob6e5c54CompareJanuary 7, 2025 15:01
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.

I like this refactor overall, I think it does simplify things and make our already confusing defs/refs management logic a bit more clear.

Thanks for adding those docstrings as well.

Some common patterns are defined as methods to avoid duplication(e.g. `create_reference_to_schema`, used to store a schema as adefinition and returns a `'definition-reference'` schema). A coupleexisting methods on the `GenerateSchema` class are moved (andrenamed to better describe what they do) to the `_Definitions`class.Proper docstrings are added to attribute and methods.Type hints are tweaked when necessary.
@ViicosViicosforce-pushed thedefinitions-improvements branch fromb6e5c54 to79bec86CompareJanuary 7, 2025 15:35
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.

I'm happy with this given the re-namings, thanks!

@ViicosViicos merged commit796fed9 intomainJan 7, 2025
62 checks passed
@ViicosViicos deleted the definitions-improvements branchJanuary 7, 2025 20:13
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.

3 participants
@Viicos@sydney-runkle@MarkusSintonen

[8]ページ先頭

©2009-2025 Movatter.jp