Skip to content

Instantly share code, notes, and snippets.

@shawnwall
Last active August 25, 2021 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnwall/6d0ae5f4a5b3e18d8403507616a3efb2 to your computer and use it in GitHub Desktop.
Save shawnwall/6d0ae5f4a5b3e18d8403507616a3efb2 to your computer and use it in GitHub Desktop.
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