Backported and Experimental Type Hints for Python 3.7+
typing_extensions module serves two related purposes:
- Enable use of new type system features on older Python versions. For example,
typing.TypeGuardis new in Python 3.10, but
typing_extensionsallows users on previous Python versions to use it too.
- Enable experimentation with new type system PEPs before they are accepted and
added to the
New features may be added to
typing_extensions as soon as they are specified
in a PEP that has been added to the python/peps
repository. If the PEP is accepted, the feature will then be added to
for the next CPython release. No typing PEP has been rejected so far, so we
haven't yet figured out how to deal with that possibility.
Starting with version 4.0.0,
Semantic Versioning. The
major version is incremented for all backwards-incompatible changes.
Therefore, it's safe to depend
typing_extensions like this:
typing_extensions >=x.y, <(x+1),
x.y is the first version that includes all features you need.
typing_extensions supports Python versions 3.7 and higher. In the future,
support for older Python versions will be dropped some time after that version
reaches end of life.
This module currently contains the following:
typingsince Python 3.11
@dataclass_transform()(see PEP 681)
LiteralString(see PEP 675)
NotRequired(see PEP 655)
Required(see PEP 655)
Self(see PEP 673)
TypeVarTuple(see PEP 646; the
typing_extensionsversion supports the
default=argument from PEP 696)
Unpack(see PEP 646)
typingsince Python 3.10
typingsince Python 3.9
Annotated(see PEP 593)
typingsince Python 3.8
typingsince Python 3.7
typingsince Python 3.5 or 3.6 (see the typing documentation for details)
ClassVar(see PEP 526)
The following have always been present in
typing, but the
typing_extensionsversions provide additional features:
Other Notes and Limitations
Certain objects were changed after they were added to
typing_extensions provides a backport even on newer Python versions:
TypedDictdoes not store runtime information about which (if any) keys are non-required in Python 3.8, and does not honor the
totalkeyword with old-style
TypedDict()in Python 3.9.0 and 3.9.1.
TypedDictalso does not support multiple inheritance with
typing.Genericon Python <3.11.
get_argslack support for
Annotatedin Python 3.8 and lack support for
@finalwas changed in Python 3.11 to set the
@overloadwas changed in Python 3.11 to make function overloads introspectable at runtime. In order to access overloads with
typing_extensions.get_overloads(), you must use
NamedTuplewas changed in Python 3.11 to allow for multiple inheritance with
- Since Python 3.11, it has been possible to inherit from
typing_extensions.Anyalso provides this capability.
TypeVargains two additional parameters,
infer_variance=, in the draft PEPs 695 and 696, which are being considered for inclusion in Python 3.12.
There are a few types whose interface was modified between different
versions of typing. For example,
typing.Sequence was modified to
typing.Reversible as of Python 3.5.3.
These changes are not backported to prevent subtle compatibility issues when mixing the differing implementations of modified classes.
Certain types have incorrect runtime behavior due to limitations of older versions of the typing module:
Concatenatewill not work with
get_origin. Certain PEP 612 special cases in user-defined
Generics are also not available.
These types are only guaranteed to work for static type checking.
To run tests, navigate into the appropriate source directory and run
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for typing_extensions-4.5.0-py3-none-any.whl