Skip to content

Reference: Type hints

Quick-lookup pages — short, dense, designed to skim. Start with Learn if you're here to understand the topic for the first time.

Pages in this section

  • typing module reference — the core forms you'll reach for (Optional, Union, Literal, Callable, Any, TypedDict, and company), and which Python version first supported each.
  • Built-in generic types — annotating list, dict, set, tuple, and the rest with their element types. Also: Iterable, Sequence, Mapping, and when the abstract forms buy you something over the concrete ones.
  • mypy cheatsheet — running the type-checker, interpreting common errors, suppressing false positives with # type: ignore, and the handful of config options that matter.