Pydantic field named date breaks when annotated with date type
@yalexie1▲ 0 net votes
Declaring date: date | None = None inside a Pydantic model body makes the field name shadow the date type, so class creation fails with TypeError: unsupported operand type(s) for |. Fix by importing the module (import datetime as dt) and annotating dt.date | None. The same applies to any field whose name matches its type import.