2323
2424--------------
2525
26- This module provides runtime support for type hints. The most fundamental
27- support consists of the types :data: `Any `, :data: `Union `, :data: `Callable `,
28- :class: `TypeVar `, and :class: `Generic `. For a specification, please see
29- :pep: `484 `. For a simplified introduction to type hints, see :pep: `483 `.
26+ This module provides runtime support for type hints. For the original
27+ specification of the typing system, see :pep: `484 `. For a simplified
28+ introduction to type hints, see :pep: `483 `.
3029
3130
3231The function below takes and returns a string and is annotated as follows::
@@ -47,16 +46,18 @@ For a summary of deprecated features and a deprecation timeline, please see
4746
4847.. seealso ::
4948
50- For a quick overview of type hints, refer to
51- ` this cheat sheet < https:// mypy.readthedocs.io/en/stable/cheat_sheet_py3.html >`_.
49+ ` "Typing cheat sheet" < https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html >`_
50+ A quick overview of type hints (hosted at the mypy docs)
5251
53- The "Type System Reference" section of https://mypy.readthedocs.io/ -- since
54- the Python typing system is standardised via PEPs, this reference should
55- broadly apply to most Python type checkers, although some parts may still be
56- specific to mypy.
52+ "Type System Reference" section of ` the mypy docs < https://mypy.readthedocs.io/en/stable/index.html >`_
53+ The Python typing system is standardised via PEPs, so this reference
54+ should broadly apply to most Python type checkers. (Some parts may still
55+ be specific to mypy.)
5756
58- The documentation at https://typing.readthedocs.io/ serves as useful reference
59- for type system features, useful typing related tools and typing best practices.
57+ `"Static Typing with Python" <https://typing.readthedocs.io/en/latest/ >`_
58+ Type-checker-agnostic documentation written by the community detailing
59+ type system features, useful typing related tools and typing best
60+ practices.
6061
6162.. _relevant-peps :
6263
@@ -654,33 +655,16 @@ can define new custom protocols to fully enjoy structural subtyping
654655Module contents
655656===============
656657
657- The module defines the following classes, functions and decorators.
658-
659- .. note ::
660-
661- This module defines several deprecated aliases to pre-existing
662- standard library classes. These were originally included in the typing
663- module in order to support parameterizing these generic classes using ``[] ``.
664- However, the aliases became redundant in Python 3.9 when the
665- corresponding pre-existing classes were enhanced to support ``[] ``.
666-
667- The redundant types are deprecated as of Python 3.9 but no
668- deprecation warnings are issued by the interpreter.
669- It is expected that type checkers will flag the deprecated types
670- when the checked program targets Python 3.9 or newer.
671-
672- The deprecated types will be removed from the :mod: `typing ` module
673- no sooner than the first Python version released 5 years after the release of Python 3.9.0.
674- See details in :pep: `585 `—*Type Hinting Generics In Standard Collections *.
675-
658+ The ``typing `` module defines the following classes, functions and decorators.
676659
677660Special typing primitives
678661-------------------------
679662
680663Special types
681664"""""""""""""
682665
683- These can be used as types in annotations and do not support ``[] ``.
666+ These can be used as types in annotations. They do not support subscription
667+ using ``[] ``.
684668
685669.. data :: Any
686670
@@ -890,7 +874,8 @@ These can be used as types in annotations and do not support ``[]``.
890874Special forms
891875"""""""""""""
892876
893- These can be used as types in annotations using ``[] ``, each having a unique syntax.
877+ These can be used as types in annotations. They all support subscription using
878+ ``[] ``, but each has a unique syntax.
894879
895880.. data :: Tuple
896881
@@ -1471,7 +1456,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
14711456Building generic types and type aliases
14721457"""""""""""""""""""""""""""""""""""""""
14731458
1474- The following objects are not used directly in annotations. Instead, they are building blocks
1459+ The following classes should not be used directly as annotations.
1460+ Their intended purpose is to be building blocks
14751461for creating generic types and type aliases.
14761462
14771463These objects can be created through special syntax
@@ -1962,7 +1948,9 @@ without the dedicated syntax, as documented below.
19621948Other special directives
19631949""""""""""""""""""""""""
19641950
1965- These are not used in annotations. They are building blocks for declaring types.
1951+ These functions and classes should not be used directly as annotations.
1952+ Their intended purpose is to be building blocks for creating and declaring
1953+ types.
19661954
19671955.. class :: NamedTuple
19681956
@@ -2386,7 +2374,8 @@ These are not used in annotations. They are building blocks for declaring types.
23862374Protocols
23872375---------
23882376
2389- These protocols are decorated with :func: `runtime_checkable `.
2377+ The following protocols are provided by the typing module. All are decorated
2378+ with :func: `@runtime_checkable <runtime_checkable> `.
23902379
23912380.. class :: SupportsAbs
23922381
@@ -3024,6 +3013,21 @@ Constant
30243013Deprecated aliases
30253014------------------
30263015
3016+ This module defines several deprecated aliases to pre-existing
3017+ standard library classes. These were originally included in the typing
3018+ module in order to support parameterizing these generic classes using ``[] ``.
3019+ However, the aliases became redundant in Python 3.9 when the
3020+ corresponding pre-existing classes were enhanced to support ``[] ``.
3021+
3022+ The redundant types are deprecated as of Python 3.9 but no
3023+ deprecation warnings are issued by the interpreter.
3024+ It is expected that type checkers will flag the deprecated types
3025+ when the checked program targets Python 3.9 or newer.
3026+
3027+ The deprecated types will be removed from the :mod: `typing ` module
3028+ no sooner than the first Python version released 5 years after the release of Python 3.9.0.
3029+ See details in :pep: `585 `—*Type Hinting Generics In Standard Collections *.
3030+
30273031.. _corresponding-to-built-in-types :
30283032
30293033Aliases to built-in types
0 commit comments