Type Hints & Annotations
Type Hints Basics
Adding optional type annotations to Python — variable annotations, function signatures, return types, and how type hints improve code quality and IDE support.
typing Module
The typing module — Optional, Union, Any, Callable, and modern equivalents in Python 3.9+ and 3.10+ for complex type annotations.
Generics
TypeVar and Generic — building reusable, type-safe containers and functions that work with any type while maintaining static checking.
Type Aliases
Creating reusable type shortcuts — named types for complex annotations, improving readability and reducing repetition in type hints.
mypy
Static type checking with mypy — configuring, running, understanding errors, and integrating type checking into your development workflow.
Protocols
Structural subtyping with Protocol — defining interfaces based on shape rather than inheritance, enabling duck typing with static checking.
Runtime Type Checking
Runtime type validation with isinstance, type guards, Pydantic, and dataclass validation — enforcing types at runtime when static checking is not enough.