17
17
18
18
--------------
19
19
20
- This module provides runtime support for type hints as specified by
21
- :pep: `484 `, :pep: `526 `, :pep: `544 `, :pep: `586 `, :pep: `589 `, :pep: `591 `,
22
- :pep: `593 `, :pep: `612 `, :pep: `613 ` and :pep: `647 `.
23
- The most fundamental support consists of the types :data: `Any `, :data: `Union `,
24
- :data: `Tuple `, :data: `Callable `, :class: `TypeVar `, and
25
- :class: `Generic `. For full specification please see :pep: `484 `. For
26
- a simplified introduction to type hints see :pep: `483 `.
20
+ This module provides runtime support for type hints. The most fundamental
21
+ support consists of the types :data: `Any `, :data: `Union `, :data: `Tuple `,
22
+ :data: `Callable `, :class: `TypeVar `, and :class: `Generic `. For a full
23
+ specification, please see :pep: `484 `. For a simplified introduction to type
24
+ hints, see :pep: `483 `.
27
25
28
26
29
27
The function below takes and returns a string and is annotated as follows::
@@ -35,6 +33,42 @@ In the function ``greeting``, the argument ``name`` is expected to be of type
35
33
:class: `str ` and the return type :class: `str `. Subtypes are accepted as
36
34
arguments.
37
35
36
+ .. _relevant-peps :
37
+
38
+ Relevant PEPs
39
+ =============
40
+
41
+ Since the initial introduction of type hints in :pep: `484 ` and :pep: `483 `, a
42
+ number of PEPs have modified and enhanced Python's framework for type
43
+ annotations. These include:
44
+
45
+ * :pep: `526 `: Syntax for Variable Annotations
46
+ *Introducing * syntax for annotating variables outside of function
47
+ definitions, and :data: `ClassVar `
48
+ * :pep: `544 `: Protocols: Structural subtyping (static duck typing)
49
+ *Introducing * :class: `Protocol ` and the
50
+ :func: `@runtime_checkable<runtime_checkable> ` decorator
51
+ * :pep: `585 `: Type Hinting Generics In Standard Collections
52
+ *Introducing * the ability to use builtin collections and ABCs as
53
+ :term: `generic types<generic type> `
54
+ * :pep: `586 `: Literal Types
55
+ *Introducing * :data: `Literal `
56
+ * :pep: `589 `: TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys
57
+ *Introducing * :class: `TypedDict `
58
+ * :pep: `591 `: Adding a final qualifier to typing
59
+ *Introducing * :data: `Final ` and the :func: `@final<final> ` decorator
60
+ * :pep: `593 `: Flexible function and variable annotations
61
+ *Introducing * :data: `Annotated `
62
+ * :pep: `604 `: Allow writing union types as ``X | Y ``
63
+ *Introducing * :data: `types.UnionType ` and the ability to use
64
+ the binary-or operator ``| `` as syntactic sugar for a union of types
65
+ * :pep: `612 `: Parameter Specification Variables
66
+ *Introducing * :class: `ParamSpec ` and :data: `Concatenate `
67
+ * :pep: `613 `: Explicit Type Aliases
68
+ *Introducing * :data: `TypeAlias `
69
+ * :pep: `647 `: User-Defined Type Guards
70
+ *Introducing * :data: `TypeGuard `
71
+
38
72
.. _type-aliases :
39
73
40
74
Type aliases
0 commit comments