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
Ellipsis does not mark annotated field as required in create_model #8634
Comments
There was minimal change from v2.1.0 to v2.1.1 so hopefully the cause should be easy to identify for someone familiar with the code. v2.1.0...v2.1.1 |
Thanks for reporting this. This does look like a bug. We'll look to fix this for v2.7! |
I just had a quick look. The symptoms are similar too #8629 but this is indeed a bug. As @jackmpcollins pointed out, the changes introduced between 2.1.0 and 2.1.1 are the source. Just a few details: I'll open a PR |
Fantastic! Ping me when you need a review 🚀 ! |
I think this was the change that caused the bug in the first place: https://github.com/pydantic/pydantic/pull/6862/files |
Is the fix released ? As with version 2.6.3 this appears not yet fixed: class Foo(BaseModel):
x: Annotated[int, Field()] = ...
from f in Foo.model_fields.items():
print(f)
# 2.6.3
# ('x', FieldInfo(annotation=int, required=False, default=Ellipsis)) Thanks |
It's fixed on |
Initial Checks
Description
Ellipsis is being recognized as a default value for fields that have
Annotated[<type>, Field()]
type annotation. These fields should instead be marked as required with no default.This works correctly in v2.1.0 and is broken in v2.1.1 and in the latest version v2.5.3.
This is mainly an issue for me using
create_model
where Ellipsis must be used to indicate the absence of a default value.Relevant docs https://docs.pydantic.dev/latest/concepts/models/#required-fields
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: