-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Recommend against using Ellipsis (...) with Field
#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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| #> [('a',), ('b',), ('c',), ('d',), ('e',)] | ||
| ``` | ||
|
|
||
| ## Required fields |
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.
This is the updated documentation, the rest is just switching from Field(...) to Field()
Deploying pydantic-docs with
|
| Latest commit: |
76cc978
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8f7cad7a.pydantic-docs.pages.dev |
| Branch Preview URL: | https://field-ellipsis.pydantic-docs.pages.dev |
| # Also remove it from the attributes set, otherwise | ||
| # `GenerateSchema._common_field_schema` mistakenly | ||
| # uses it: | ||
| self._attributes_set.pop('default', None) |
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.
See the added test for an example
| 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' |
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.
As a consequence of the fixed bug: a slight change in schemas because AnyState is no longer considered to have a default value of ....
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.
Thanks for explaining. I'm surprised this changed the schema - I guess there was a with_default schema here previously?
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.
yes exactly
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.
Seems like a bug fix.
CodSpeed Performance ReportMerging #10661 will not alter performanceComparing Summary
|
8a0ce6d to
a1d8176
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Nice. One quick question, but looks great.
Surprised re how many places we used this in the docs / examples. Nice job with the update!
| 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' |
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.
Thanks for explaining. I'm surprised this changed the schema - I guess there was a with_default schema here previously?
Also fix a bug where under certain scenarios, a `Field` function inside `Annotated` metadata would retain the `Ellipsis` as a default value. Also make `PrivateAttr` on par with `Field` and the special casing of `Ellipsis`.
a1d8176 to
76cc978
Compare
Also fix a bug where under certain scenarios, a
Fieldfunction insideAnnotatedmetadata would retain theEllipsisas a default value.Also make
PrivateAttron par withFieldand the special casing ofEllipsis.Change Summary
Related issue number
Checklist