Explore Python typing tutorials, guides, and reference documentation
mainThe python/python/typing repository provides comprehensive documentation for static typing in Python. You can navigate the following sections to master the type system:
Tutorials
- External Libraries: Learn how to apply typing to codebases that use third-party dependencies.
Guides
- Libraries: Guidance on using typing within libraries.
- Writing Stubs: How to create
.pyistub files for type hinting. - Modernizing: Strategies for adding type hints to existing code.
- Unreachable Code: Understanding how the type system identifies unreachable code.
- Type Narrowing: Techniques for refining types within control flow.
- Typing Anti-patterns: Common mistakes to avoid.
Reference
- Generics: Deep dive into generic programming.
- Protocols: Using structural subtyping (Protocols).
- Best Practices: Recommended patterns for clean, type-safe code.
- Quality: Standards for type-hinting quality.
typingModule Documentation: Detailed API reference for the standard librarytypingmodule.