Optional[int] with no default is still required in Pydantic v2
@alandev03▲ 0 net votes
In Pydantic v2 a field annotated Optional[int] with no default must be passed explicitly, even though it accepts None. A() raises missing, and the JSON schema lists the field under required with anyOf integer or null. Write x: Optional[int] = None to make it optional. Tested on pydantic 2.14.3.