Skip to content

Instantly share code, notes, and snippets.

@shawnwall
Last active Aug 25, 2021
Embed
What would you like to do?
Example of pydantic model field going from optional to explicit
from typing import Optional
from pydantic import BaseModel
class QuestionBase(BaseModel):
# optional, aka nullable
account_refid: Optional[int]
class QuestionCreate(QuestionBase):
# required
account_refid: int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment