{"id":249,"library":"typing-extensions","title":"typing-extensions","description":"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.","status":"active","version":"4.15.0","language":"python","source_language":"en","source_url":"https://github.com/python/typing_extensions","tags":["typing","type-hints","backport","mypy","pyright","annotations","stdlib"],"install":[{"cmd":"pip install typing-extensions","lang":"bash","label":"Latest"},{"cmd":"pip install 'typing-extensions~=4.15'","lang":"bash","label":"Pinned minor (recommended)"}],"dependencies":[],"imports":[{"note":"typing_extensions version has additional features (ReadOnly, closed/extra_items via PEP 728) and bug fixes not present in the stdlib version on older Python releases. Prefer typing_extensions.TypedDict when targeting <3.13 for full feature parity.","wrong":"from typing import TypedDict","symbol":"TypedDict","correct":"from typing_extensions import TypedDict"},{"note":"Safe to import from typing_extensions on all supported versions; re-exported from stdlib typing internally.","symbol":"Annotated","correct":"from typing_extensions import Annotated"},{"note":"typing_extensions.Protocol has backported isinstance() fixes and allows @runtime_checkable interop. On Python <3.12 the stdlib version has known isinstance() performance and correctness issues.","wrong":"from typing import Protocol","symbol":"Protocol","correct":"from typing_extensions import Protocol"},{"note":"Backport of PEP 673; available in stdlib typing only from Python 3.11.","symbol":"Self","correct":"from typing_extensions import Self"},{"note":"Backport of PEP 613; in stdlib from Python 3.10. Use typing_extensions version for Python 3.9 compatibility.","symbol":"TypeAlias","correct":"from typing_extensions import TypeAlias"},{"note":"Backport of PEP 695 type alias syntax; native only in Python 3.12+.","symbol":"TypeAliasType","correct":"from typing_extensions import TypeAliasType"},{"note":"Backport of PEP 647; in stdlib from Python 3.10. Consider TypeIs (PEP 742, 4.10+) for more intuitive narrowing semantics.","symbol":"TypeGuard","correct":"from typing_extensions import TypeGuard"},{"note":"Added in 4.10.0 (PEP 742). Prefer over TypeGuard for most narrowing use-cases — TypeIs has stricter but more predictable semantics.","symbol":"TypeIs","correct":"from typing_extensions import TypeIs"},{"note":"Backport of PEP 698; in stdlib from Python 3.12. Decorator sets .__override__ = True at runtime.","symbol":"override","correct":"from typing_extensions import override"},{"note":"Backport of PEP 702 (added in 4.5.0). Raises DeprecationWarning at call site. Was a common ImportError source when frameworks (FastAPI, Pydantic) required >=4.8.0 but environments had older pinned versions.","symbol":"deprecated","correct":"from typing_extensions import deprecated"},{"note":"Added in 4.13.0. Backport of inspect.get_annotations with PEP 649 features. Do not use inspect.get_annotations directly if you need PEP 649 lazy evaluation semantics.","symbol":"get_annotations","correct":"from typing_extensions import get_annotations"},{"note":"Added in 4.13.0. Use instead of typing.get_type_hints() when you need fine-grained ForwardRef evaluation control under PEP 649.","symbol":"evaluate_forward_ref","correct":"from typing_extensions import evaluate_forward_ref"},{"note":"typing.ByteString is deprecated and removed in Python 3.14. Use typing_extensions.Buffer for buffer-protocol types instead.","wrong":"from typing import ByteString","symbol":"Buffer","correct":"from typing_extensions import Buffer"},{"note":"Backport of PEP 675; in stdlib from Python 3.11.","symbol":"LiteralString","correct":"from typing_extensions import LiteralString"},{"note":"Backport of typing.Never (3.11+). Prefer over NoReturn for non-return-type positions.","symbol":"Never","correct":"from typing_extensions import Never"}],"quickstart":{"code":"from typing_extensions import (\n    TypedDict,\n    NotRequired,\n    ReadOnly,\n    Annotated,\n    Self,\n    TypeAlias,\n    override,\n    deprecated,\n    TypeIs,\n    Protocol,\n    runtime_checkable,\n)\nimport sys\n\n# TypedDict with optional and read-only fields (PEP 655, PEP 705)\nclass Movie(TypedDict):\n    title: ReadOnly[str]\n    year: NotRequired[int]\n\nmovie: Movie = {\"title\": \"Blade Runner\"}\n\n# TypeAlias for clarity\nVector: TypeAlias = list[float]\n\n# Self in method signatures\nclass Builder:\n    def set_name(self, name: str) -> Self:\n        self.name = name\n        return self\n\n# Protocol with runtime checking\n@runtime_checkable\nclass Drawable(Protocol):\n    def draw(self) -> None: ...\n\n# TypeIs for narrowing\ndef is_str_list(val: list[object]) -> TypeIs[list[str]]:\n    return all(isinstance(x, str) for x in val)\n\n# deprecated decorator\n@deprecated(\"Use new_api() instead\")\ndef old_api() -> None:\n    pass\n\n# override for subclass safety\nclass Base:\n    def compute(self) -> int:\n        return 0\n\nclass Child(Base):\n    @override\n    def compute(self) -> int:\n        return 42\n\nprint(f\"typing_extensions quickstart OK — Python {sys.version}\")\n","lang":"python","description":"Demonstrates the most commonly used constructs: TypedDict with ReadOnly/NotRequired fields, TypeAlias, Self, runtime_checkable Protocol, TypeIs narrowing, the @deprecated decorator, and @override."},"warnings":[{"fix":"Pin `typing-extensions~=4.13` for Python 3.8 environments, or upgrade Python.","message":"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.","severity":"breaking","affected_versions":"<4.14.0"},{"fix":"Replace `typing.ByteString` or `typing_extensions.ByteString` with `typing_extensions.Buffer` (equivalent to `collections.abc.Buffer` on 3.12+).","message":"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.","severity":"breaking","affected_versions":"4.x (all)"},{"fix":"Use the class-based TypedDict syntax: `class Movie(TypedDict): title: str`.","message":"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+.","severity":"breaking","affected_versions":"4.x on Python >=3.12"},{"fix":"Stop using `no_type_check_decorator`; it is unsupported by type checkers and has no maintained replacement.","message":"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+.","severity":"breaking","affected_versions":">=4.14.0"},{"fix":"Use `typing-extensions~=4.14` (or whichever minor first includes your needed features), not `==4.14.1`.","message":"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)`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `isinstance(obj, (typing.X, typing_extensions.X))` or compare with `in (typing.X, typing_extensions.X)` in runtime isinstance/issubclass guards.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure `typing-extensions>=4.8.0` is in your dependency list; audit layered environments (Docker layers, conda + pip) for duplicate installs at different versions.","message":"`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'`.","severity":"gotcha","affected_versions":"<4.5.0"}],"env_vars":null,"last_verified":"2026-05-12T12:20:05.545Z","next_check":"2026-06-25T00:00:00.000Z","problems":[{"fix":"pip install typing-extensions","cause":"The typing-extensions package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'typing_extensions'"},{"fix":"from typing_extensions import TypeGuard","cause":"TypeGuard was introduced in Python 3.10; on older Python versions, it must be imported from typing_extensions.","error":"ImportError: cannot import name 'TypeGuard' from 'typing'"},{"fix":"from typing_extensions import Self","cause":"Self (from PEP 673) was introduced in Python 3.11; on older Python versions, it must be imported from typing_extensions.","error":"ImportError: cannot import name 'Self' from 'typing'"},{"fix":"from typing_extensions import TypeAlias","cause":"TypeAlias (from PEP 613) was introduced in Python 3.10; on older Python versions, it must be imported from typing_extensions.","error":"ImportError: cannot import name 'TypeAlias' from 'typing'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"18.1M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"18.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":1.7,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":1.7,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2,"disk_size":"19.9M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2,"disk_size":"19.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":2,"disk_size":"20M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":2,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.8,"disk_size":"11.8M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":1.8,"disk_size":"11.8M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":1.8,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":1.8,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":2.1,"disk_size":"11.4M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":2.1,"disk_size":"11.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.9,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.9,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"17.6M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"17.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}