Static Typing with Python¶
Guides¶
Reference¶
See also
The documentation at https://mypy.readthedocs.io/ is relatively accessible and complete. Particularly refer to the “Type System Reference” section of the docs – since the Python typing system is standardised via PEPs, this information should apply to most Python type checkers.
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 compatibility
- Type aliases
- Literals
- Protocols
- Callables
@overload
- Dataclasses
- Typed dictionaries
- Read-only Items
- Tuples
- Named Tuples
- Type narrowing
- Type checker directives
- Distributing type information
- Historical and deprecated features
- Glossary
Indices and tables¶
Discussions and Support¶
Typing PEPs¶
https://peps.python.org/topic/typing
PEP 482, literature overview on type hints
PEP 483, background on type hints
PEP 484, type hints
PEP 526, variable annotations and
ClassVar
PEP 544,
Protocol
PEP 561, distributing typed packages
PEP 563,
from __future__ import annotations
PEP 585, subscriptable generics in the standard library
PEP 586,
Literal
PEP 589,
TypedDict
PEP 591,
Final
PEP 593,
Annotated
PEP 604, union syntax with
|
PEP 612,
ParamSpec
PEP 613,
TypeAlias
PEP 646, variadic generics and
TypeVarTuple
PEP 647,
TypeGuard
PEP 649 (draft), lazy evaluation of annotations
PEP 655,
Required
andNotRequired
PEP 673,
Self
PEP 675,
LiteralString
PEP 677 (rejected),
(int, str) -> bool
callable type syntaxPEP 681,
@dataclass_transform()
PEP 688,
Buffer
PEP 692,
Unpack[TypedDict]
for**kwargs
PEP 695,
class Class[T]:
type parameter syntax andtype X
type alias syntaxPEP 696 (draft), defaults for type variables
PEP 698,
@override
PEP 702,
@deprecated()
PEP 705 (draft),
TypedDict
with read-only itemsPEP 718 (draft), subscriptable functions
PEP 724 (withdrawn), stricter
TypeGuard
PEP 727 (draft),
Doc
inAnnotated
PEP 728 (draft),
TypedDict
with typed extra itemsPEP 729, typing governance process
PEP 742 (draft),
TypeIs