Search across all documentation pages
13 pages in this section.
What a type hint actually is, why the interpreter mostly ignores it, and how a separate static checker turns annotations into a second, optional verification layer over Python's dynamic runtime - the mental model behind every other page in this section.
Learn Python type hint basics, including annotating variables, functions, and collections, and handling optional values with None.
Learn to use built-in collection generics like list[int] and collections.abc types to precisely describe container types in Python.
Learn how to use Optional, Union, and the | operator in Python for nullable types, narrowing, and handling multiple input representations.
Understand Python's Protocol for static duck typing. Learn to define structural interfaces and use @runtime_checkable for runtime type checks.
Learn how TypedDict adds static type checking to dictionaries for JSON and records, and how NamedTuple creates immutable, lightweight data structures.
Configure mypy and pyright for Python projects. Learn to set up type checking in pyproject.toml, integrate with CI, and adjust strictness.
Learn best practices for Python type hints. Discover where to apply types for maximum impact, improve code readability, and prevent common bugs.
A single-page roundup of every highlight bullet from the 12 pages in the Type Hints section, grouped by source page so you can scan all 48 takeaways without opening each article individually.