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

Recommend against usingEllipsis (...) withField#10661

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 1 commit intomainfromfield-ellipsis
Oct 21, 2024
Merged

Conversation

Viicos
Copy link
Member

Also fix a bug where under certain scenarios, aField function insideAnnotated metadata would retain theEllipsis as a default value.

Also makePrivateAttr on par withField and the special casing ofEllipsis.

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

sydney-runkle reacted with thumbs up emoji
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelOct 18, 2024
@@ -1359,25 +1359,23 @@ print(error_locations)

## Required fields
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is the updated documentation, the rest is just switching fromField(...) toField()

@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedOct 18, 2024
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:76cc978
Status: ✅  Deploy successful!
Preview URL:https://8f7cad7a.pydantic-docs.pages.dev
Branch Preview URL:https://field-ellipsis.pydantic-docs.pages.dev

View logs

Comment on lines +212 to +215
# Also remove it from the attributes set, otherwise
# `GenerateSchema._common_field_schema` mistakenly
# uses it:
self._attributes_set.pop('default', None)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

See the added test for an example

sydney-runkle reacted with thumbs up emoji
adapter = TypeAdapter(AnyState)

assert adapter.core_schema['schema']['type'] == 'tagged-union'
for definition in adapter.core_schema['definitions']:
if definition['schema']['model_name'] in ['NestedState', 'LoopState']:
assert definition['schema']['fields']['substate']['schema']['schema']['type'] == 'tagged-union'
assert definition['schema']['fields']['substate']['schema']['type'] == 'tagged-union'
Copy link
MemberAuthor

@ViicosViicosOct 18, 2024
edited
Loading

Choose a reason for hiding this comment

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

As a consequence of the fixed bug: a slight change in schemas becauseAnyState is no longer considered to have a default value of....

sydney-runkle reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining. I'm surprised this changed the schema - I guess there was awith_default schema here previously?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

yes exactly

sydney-runkle reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a bug fix.

Viicos reacted with thumbs up emoji
@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedOct 18, 2024
edited
Loading

CodSpeed Performance Report

Merging#10661 willnot alter performance

Comparingfield-ellipsis (76cc978) withmain (220b2f6)

Summary

✅ 44 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  fields.py
Project Total 

This report was generated bypython-coverage-comment-action

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.

Nice. One quick question, but looks great.

Surprised re how many places we used this in the docs / examples. Nice job with the update!

adapter = TypeAdapter(AnyState)

assert adapter.core_schema['schema']['type'] == 'tagged-union'
for definition in adapter.core_schema['definitions']:
if definition['schema']['model_name'] in ['NestedState', 'LoopState']:
assert definition['schema']['fields']['substate']['schema']['schema']['type'] == 'tagged-union'
assert definition['schema']['fields']['substate']['schema']['type'] == 'tagged-union'
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining. I'm surprised this changed the schema - I guess there was awith_default schema here previously?

Also fix a bug where under certain scenarios, a `Field` functioninside `Annotated` metadata would retain the `Ellipsis` as adefault value.Also make `PrivateAttr` on par with `Field` and the special casingof `Ellipsis`.
@ViicosViicos merged commita1ffc82 intomainOct 21, 2024
62 checks passed
@ViicosViicos deleted the field-ellipsis branchOctober 21, 2024 08:40
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.

2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp