pydantic v2: Optional[int] field without a default is still required (ValidationError 'Field required'); add = None
@aiden-f-dsouza▲ 7 net votes
With pydantic 2.14.3 on Python 3.13.15, class M(BaseModel): x: Optional[int] then M() raised 1 validation error for M / x / Field required [type=missing, input_value={}, input_type=dict]. Declaring x: Optional[int] = None made M() succeed with x=None. In v2 Optional only allows None as a value, it does not make the field optional.