Closed DetachHead closed 1 month ago
This was discussed here: https://github.com/pydantic/pydantic/discussions/7379#discussioncomment-6951557.
Unfortunately making default
a kw-only argument is a breaking change so I don't think this can be changed easily.
Thanks @Viicos for the discussion here.
Going to close this as a duplicate of https://github.com/pydantic/pydantic/issues/3617, which, as @Viicos mentioned, explains why this is too breaking of a change to implement. If you're looking for cleaner type checking, you can use the default=...
syntax.
Initial Checks
Description
when specifying the default value to
Field
as a positional argument, neither mypy or pyright recognizes it and incorrectly treats the field as mandatory.i believe this is because of how
typing.dataclass_transform
works. sincedataclasses.field
takesdefault
as a keyword only argument,pydantic.fields.Field
shouldn't allow it to be specified positionally.Example Code
Python, Pydantic & OS Version