typing-extensions
typing-extensions provides backported and experimental type hints for Python, serving two purposes: enabling use of new type system features on older Python versions (e.g., TypeGuard from 3.10 is available on 3.9+), and enabling experimentation with new PEP-proposed typing constructs before they land in the standard library. The library also re-exports all names from the standard typing module, so it can serve as a single import source. Current version is 4.15.0 (as of early 2026); feature releases follow an irregular cadence under Semantic Versioning where only the major version is bumped for breaking changes.
Warnings
- breaking Python 3.8 support dropped in 4.14.0. Projects that still run on CPython/PyPy 3.8 must pin to typing_extensions<4.14.
- breaking typing.ByteString is not re-exported and is removed in Python 3.14. Any code that relied on typing_extensions re-exporting ByteString will break.
- breaking TypedDict keyword-argument construction syntax (e.g., `Movie = TypedDict('Movie', title=str)`) emits DeprecationWarning on Python 3.12 and raises TypeError on Python 3.13+.
- breaking typing_extensions does not re-export names removed from typing, including the anticipated removal of `typing.no_type_check_decorator` in Python 3.15. Importing it from typing_extensions will raise ImportError on 4.14+.
- gotcha Pinning to `typing-extensions~=x.y.z` (patch-level) defeats Semantic Versioning and can block important bugfixes. The correct specifier is `typing-extensions~=x.y` (minor-level) or `>=x.y,<(x+1)`.
- gotcha When introspecting types at runtime (e.g., `isinstance(obj, some_protocol)`), always check for both `typing.X` and `typing_extensions.X` variants. Future releases may re-export a separate backport version that is not `is`-identical to the stdlib one.
- gotcha `deprecated` (PEP 702) was added in 4.5.0 but many ecosystems (FastAPI, Pydantic) require >=4.8.0. Environments with conda-pinned or transitive older typing_extensions produce `ImportError: cannot import name 'deprecated'`.
Install
-
pip install typing-extensions -
pip install 'typing-extensions~=4.15'
Imports
- TypedDict
from typing_extensions import TypedDict
- Annotated
from typing_extensions import Annotated
- Protocol
from typing_extensions import Protocol
- Self
from typing_extensions import Self
- TypeAlias
from typing_extensions import TypeAlias
- TypeAliasType
from typing_extensions import TypeAliasType
- TypeGuard
from typing_extensions import TypeGuard
- TypeIs
from typing_extensions import TypeIs
- override
from typing_extensions import override
- deprecated
from typing_extensions import deprecated
- get_annotations
from typing_extensions import get_annotations
- evaluate_forward_ref
from typing_extensions import evaluate_forward_ref
- Buffer
from typing_extensions import Buffer
- LiteralString
from typing_extensions import LiteralString
- Never
from typing_extensions import Never
Quickstart
from typing_extensions import (
TypedDict,
NotRequired,
ReadOnly,
Annotated,
Self,
TypeAlias,
override,
deprecated,
TypeIs,
Protocol,
runtime_checkable,
)
import sys
# TypedDict with optional and read-only fields (PEP 655, PEP 705)
class Movie(TypedDict):
title: ReadOnly[str]
year: NotRequired[int]
movie: Movie = {"title": "Blade Runner"}
# TypeAlias for clarity
Vector: TypeAlias = list[float]
# Self in method signatures
class Builder:
def set_name(self, name: str) -> Self:
self.name = name
return self
# Protocol with runtime checking
@runtime_checkable
class Drawable(Protocol):
def draw(self) -> None: ...
# TypeIs for narrowing
def is_str_list(val: list[object]) -> TypeIs[list[str]]:
return all(isinstance(x, str) for x in val)
# deprecated decorator
@deprecated("Use new_api() instead")
def old_api() -> None:
pass
# override for subclass safety
class Base:
def compute(self) -> int:
return 0
class Child(Base):
@override
def compute(self) -> int:
return 42
print(f"typing_extensions quickstart OK — Python {sys.version}")