Python/Types
- Indicate the type of a variable, is optional.
- Benefits, is warnings from editors if used wrong, or passing wrong type.
Use pydantic to validate incoming data, by creating a basemodel class.
# e.g. from pydantic import BaseModel class User(BaseModel): id: int name = "John Doe" signup_ts: Optional[datetime] = None friends: List[int] = []
Python/FastApi also uses pydantic + types to auto validate incoming data when building an api.