Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.2k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -1359,25 +1359,23 @@ print(error_locations) | |||
## 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 fromField(...)
toField()
cloudflare-workers-and-pagesbot commentedOct 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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
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' |
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 becauseAnyState
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 awith_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-hqbot commentedOct 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
CodSpeed Performance ReportMerging#10661 willnot alter performanceComparing Summary
|
Coverage reportClick to see where and how coverage changed
This report was generated bypython-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!
Uh oh!
There was an error while loading.Please reload this page.
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' |
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 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`.
a1ffc82
intomainUh oh!
There was an error while loading.Please reload this page.
Also fix a bug where under certain scenarios, a
Field
function insideAnnotated
metadata would retain theEllipsis
as a default value.Also make
PrivateAttr
on par withField
and the special casing ofEllipsis
.Change Summary
Related issue number
Checklist