~/talk

"Validating Complex Types Using Pydantic"

Talkat PyOhio 2024 · 2024-07-27..07-28· [python]
links:none on file
slides:none on file

Shows how to turn typing metadata into runtime checks using Pydantic: use Annotated/TypeAlias plus Pydantic’s Field and after_validator to express constraints (example: positive int and even-length string) and three validator entry points—BaseModel, a function decorator, and TypeAdapter—to validate inputs and return values. Demonstrates validating Pandas DataFrame columns and dtypes and PyTorch Tensor shapes, devices and dtypes, including a custom DS validator package that wraps Pydantic config, provides built-in torch/numpy/pandas validators, and a decorator to create reusable tensor-dimension checks that raise clear validation errors.

AI-written summary · about

  1. 0:00Introduction
  2. 1:08Complex types in Python
  3. 7:56Type aliases for clarity
  4. 13:35Validating with Pydantic
  5. 16:25Data science validation basics
  6. 20:41DS Validator package
  7. 27:11Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.