4

Those two concepts Field and Annotated seem very similar in functionality. For example, I can define the same variable in any way as:

temperature: float = Field(0.0, ge=0, le=1)
temperature: Annotated[confloat(ge=0, le=1),...] = 0.0

Is there any drawback of using only Field or Annotated?

gench
  • 1,063
  • 1
  • 11
  • 17

1 Answers1

0

Similar question: How to use python typing.Annotated? (see comments)

Annotated it is the typing.Annotated. See all possibilities here https://peps.python.org/pep-0593/

But Field it is only pydantic method for field description. See pydantic doct https://docs.pydantic.dev/usage/schema/#typingannotated-fields

Denis Artyushin
  • 301
  • 1
  • 1
  • 7