Python · Section 9
Type Hints and Static Typing
How to annotate variables, collections, and functions; the advanced typing tools for a dict with a known shape, narrowing a Union, and writing your own generic code; and the two real tools — mypy and pyright — that turn annotations into an enforced check.
This section
Python Typing - Type Hints & AnnotationsTech With Tim
- Core typingHow to annotate a variable, a collection, an optional or either-of value, and the handful of typing-module names — Any, Literal, Callable, TypeVar, Generic, TypeAlias, Final, Annotated — that appear across most typed Python code.3 core4 standard7 concepts
- Advanced typingA dict with a known shape, narrowing a Union after a check, writing your own generic class or function, and the substitution rule (variance) behind it. Protocol and structural typing — this subsection's other two roadmap items — are taught in Object-Oriented Python's Abstract classes and interfaces subsection; see that subsection's Duck typing and protocols group rather than duplicating it here.3 standard1 reference4 concepts
- ToolsThe two mainstream static type checkers, and how a team actually puts one to use — in the editor, in strict mode, and as a mandatory CI check.1 core1 standard2 concepts

