Static Typing with Python¶
Tutorials¶
Guides¶
Reference¶
See also
The documentation athttps://mypy.readthedocs.io/ is relatively accessibleand complete.
Specification¶
- Specification for the Python type system
- The Python Type System
- Meta-topics
- Type system concepts
- Type annotations
- Special types in annotations
- Generics
- Type qualifiers
- Class type assignability
- Type aliases
- Literals
- Protocols
- Callables
- Constructors
Overloads- Exceptions
- Dataclasses
- Typed dictionaries
- Tuples
- Named Tuples
- Enumerations
- Type narrowing
- Type checker directives
- Distributing type information
- Historical and deprecated features
- Glossary
Indices and tables¶
Discussions and Support¶
Typing-related Tools¶
Type Checkers¶
Development Environments¶
PyCharm, an IDE that supportstype stubs both for type checking and code completion.
Visual Studio Code, a code editor thatsupports type checking using mypy, pyright, or thePylanceextension.
Linters and Formatters¶
black, a code formatter with support fortype stub files.
flake8-pyi, a plugin for theflake8 linter that adds support for typestubs.
ruff, a linter built for speed, with support formost of the
flake8-pyirules.
Type-Hint and Stub Integration¶
autotyping, a tool whichinfers simple types from their context and inserts them as inline type-hints.
merge-pyi,a thin wrapper around
ApplyTypeAnnotationsVisitorfromlibCST that integrates .pyisignatures as inline type-hints in Python source code.
Typing PEPs¶
Seehttps://peps.python.org/topic/typing for a list of all typing-related PEPs.