⇤ ← Revision 1 as of 2021-06-13 06:09:16
459
Comment:
|
← Revision 2 as of 2021-06-13 06:12:44 ⇥
562
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
* [[Python/FastApi]] also uses pydantic + types to auto validate incoming data when building an api. |
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.