8000 [3.9] bpo-45655: Add "relevant PEPs" section to typing documentation … · python/cpython@8813a98 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8813a98

Browse files
authored
[3.9] bpo-45655: Add "relevant PEPs" section to typing documentation (GH-29297)
Backport of #29280 to the 3.9 branch.
1 parent 67a1abb commit 8813a98

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

Doc/library/typing.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717

1818
--------------
1919

20-
This module provides runtime support for type hints as specified by
21-
:pep:`484`, :pep:`526`, :pep:`544`, :pep:`586`, :pep:`589`, and :pep:`591`.
22-
The most fundamental support consists of the types :data:`Any`, :data:`Union`,
23-
:data:`Tuple`, :data:`Callable`, :class:`TypeVar`, and
24-
:class:`Generic`. For full specification please see :pep:`484`. For
25-
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`.
2625

2726

2827
The function below takes and returns a string and is annotated as follows::
@@ -34,6 +33,33 @@ In the function ``greeting``, the argument ``name`` is expected to be of type
3433
:class:`str` and the return type :class:`str`. Subtypes are accepted as
3534
arguments.
3635

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* :class:`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* :class:`Annotated`
62+
3763
Type aliases
3864
============
3965

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add a new "relevant PEPs" section to the top of the documentation for the
2+
``typing`` module. Patch by Alex Waygood.

0 commit comments

Comments
 (0)
0