@@ -9,15 +9,19 @@ Typing Extensions
9
9
Overview
10
10
========
11
11
12
- The ``typing_extensions `` module contains both backports of ``typing `` features
13
- as well as experimental types that will eventually be added to the ``typing ``
14
- module, such as ``Protocol `` (see PEP 544 for details about protocols and
15
- static duck typing) or ``TypedDict `` (see PEP 589).
16
-
17
- Users of other Python versions should continue to install and use
18
- the ``typing `` module from PyPi instead of using this one unless
19
- specifically writing code that must be compatible with multiple Python
20
- versions or requires experimental types.
12
+ The ``typing_extensions `` module serves two related purposes:
13
+
14
+ - Enable use of new type system features on older Python versions. For example,
15
+ ``typing.TypeGuard `` is new in Python 3.10, but ``typing_extensions `` allows
16
+ users on Python 3.6 through 3.9 to use it too.
17
+ - Enable experimentation with new type system PEPs before they are accepted and
18
+ added to the ``typing `` module.
19
+
20
+ New features may be added to ``typing_extensions `` as soon as they are specified
21
+ in a PEP that has been added to the `python/peps <https://github.com/python/peps >`_
22
+ repository. If the PEP is accepted, the feature will then be added to ``typing ``
23
+ for the next CPython release. No typing PEP has been rejected so far, so we
24
+ haven't yet figured out how to deal with that possibility.
21
25
22
26
Starting with version 4.0.0, ``typing_extensions `` uses
23
27
`Semantic Versioning <https://semver.org/ >`_. The
@@ -31,49 +35,62 @@ Included items
31
35
32
36
This module currently contains the following:
33
37
34
- - ``Annotated ``
35
- - ``AsyncContextManager ``
36
- - ``AsyncGenerator ``
37
- - ``AsyncIterable ``
38
- - ``AsyncIterator ``
39
- - ``Awaitable ``
40
- - ``ChainMap ``
41
- - ``ClassVar ``
42
- - ``Concatenate ``
43
- - ``ContextManager ``
44
- - ``Coroutine ``
45
- - ``Counter ``
46
- - ``DefaultDict ``
47
- - ``Deque ``
48
- - ``final ``
49
- - ``Final ``
50
- - ``Literal ``
51
- - ``NewType ``
52
- - ``NoReturn ``
53
- - ``NotRequired ``
54
- - ``overload ``
55
- - ``OrderedDict ``
56
- - ``ParamSpec ``
57
- - ``ParamSpecArgs ``
58
- - ``ParamSpecKwargs ``
59
- - ``Protocol ``
60
- - ``Required ``
61
- - ``runtime_checkable ``
62
- - ``Self ``
63
- - ``Text ``
64
- - ``Type ``
65
- - ``TypedDict ``
66
- - ``TypeAlias ``
67
- - ``TypeGuard ``
68
- - ``TYPE_CHECKING ``
69
-
70
- Python 3.7+
71
- -----------
72
-
73
- - ``get_origin ``
74
- - ``get_args ``
75
- - ``get_type_hints ``
76
-
38
+ - Experimental features
39
+
40
+ - ``NotRequired `` (see PEP 655)
41
+ - ``Required `` (see PEP 655)
42
+ - ``Self `` (see PEP 673)
43
+
44
+ - In ``typing `` since Python 3.10
45
+
46
+ - ``Concatenate `` (see PEP 612)
47
+ - ``ParamSpec `` (see PEP 612)
48
+ - ``ParamSpecArgs `` (see PEP 612)
49
+ - ``ParamSpecKwargs `` (see PEP 612)
50
+ - ``TypeAlias `` (see PEP 610)
51
+ - ``TypeGuard `` (see PEP 647)
52
+
53
+ - In ``typing `` since Python 3.9
54
+
55
+ - ``Annotated `` (see PEP 593)
56
+
57
+ - In ``typing `` since Python 3.8
58
+
59
+ - ``final `` (see PEP 591)
60
+ - ``Final `` (see PEP 591)
61
+ - ``Literal `` (see PEP 586)
62
+ - ``Protocol `` (see PEP 544)
63
+ - ``runtime_checkable `` (see PEP 544)
64
+ - ``TypedDict `` (see PEP 589)
65
+ - ``get_origin `` (``typing_extensions `` provides this function only in Python 3.7+)
66
+ - ``get_args `` (``typing_extensions `` provides this function only in Python 3.7+)
67
+
68
+ - In ``typing `` since Python 3.7
69
+
70
+ - ``OrderedDict ``
71
+
72
+ - In ``typing `` since Python 3.5 or 3.6 (see `the typing documentation
73
+ <https://docs.python.org/3.10/library/typing.html> `_ for details)
74
+
75
+ - ``AsyncContextManager ``
76
+ - ``AsyncGenerator ``
77
+ - ``AsyncIterable ``
78
+ - ``AsyncIterator ``
79
+ - ``Awaitable ``
80
+ - ``ChainMap ``
81
+ - ``ClassVar `` (see PEP 526)
82
+ - ``ContextManager ``
83
+ - ``Coroutine ``
84
+ - ``Counter ``
85
+ - ``DefaultDict ``
86
+ - ``Deque ``
87
+ - ``NewType ``
88
+ - ``NoReturn ``
89
+ - ``overload ``
90
+ - ``Text ``
91
+ - ``Type ``
92
+ - ``TYPE_CHECKING ``
93
+ - ``get_type_hints `` (``typing_extensions `` provides this function only in Python 3.7+)
77
94
78
95
Other Notes and Limitations
79
96
===========================
0 commit comments