{"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,"search_vec":"'2026':83 '3.10':32 '3.9':36 '4.15.0':79 'also':56 'annot':110 'avail':34 'backport':8,107 'break':101 'bump':99 'cadenc':89 'chang':102 'construct':46 'current':76 'e.g':29 'earli':82 'enabl':18,38 'experiment':10,39 'export':59 'extens':3,6 'featur':24,84 'follow':86 'hint':12,106 'import':74 'irregular':88 'land':49 'librari':53,55 'major':96 'modul':66 'mypi':108 'name':61 'new':21,41 'older':26 'pep':43 'pep-propos':42 'propos':44 'provid':7 'purpos':17 'pyright':109 'python':14,27 're':58 're-export':57 'releas':85 'semant':91 'serv':15,70 'singl':73 'sourc':75 'standard':52,64 'stdlib':111 'system':23 'two':16 'type':2,5,11,22,45,65,103,105 'type-hint':104 'typeguard':30 'typing-extens':1,4 'use':19 'version':28,77,92,97","created_at":"2026-03-27T17:06:08.646484+00:00","updated_at":"2026-04-16T23:49:07.842297+00:00","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,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"4.16.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/python/typing_extensions","docs":"https://typing-extensions.readthedocs.io/","changelog":"https://github.com/python/typing_extensions/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/typing-extensions/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-27","last_verified":"2026-08-27","next_check":"2026-07-27","install_tag":"verified"}}