Type Hints

list[int], dict[str, float], Optional, Union, and TypedDict

25 min · interactive lesson with runnable code and 5 graded exercises.

What you'll be able to do

  • Annotate parameters, returns, and containers
  • Explain that hints are not enforced at runtime
  • Use Optional / X | None and Union correctly
  • Describe dict-shaped data with TypedDict

The full lesson is free with an account.

Basic annotations

Containers

Optional and Union

TypedDict

Callable and Any

What hints do (and don't)

Common pitfalls