typing_extensions
typing_extensions copied to clipboard
Backported and experimental type hints for Python
I propose to add a workflow that: - Grabs `test_typing.py` from CPython - Replaces all `typing` imports with `typing_extensions` through some hackery (either sed or some cleverness with importlib) -...
Follow up from here: https://github.com/python/typing_extensions/issues/606#issuecomment-3277382801 Background: Currently CPython emits a TypeError when a mutable key from a base TypedDict is overwritten by a ReadOnly one of a child: https://github.com/python/cpython/blob/805e3368d6d07e58430654d1365283924fdf4143/Lib/typing.py#L3151 and...
Discovered by running the CPython 3.12 test_typing.py over typing_extensions. https://github.com/JanEricNitschke/typing_extensions/actions/runs/17633620675/job/50105726688#step:7:38 Originally failing test: https://github.com/python/cpython/blob/3.12/Lib/test/test_typing.py#L4047 Current situation in 3.14: https://github.com/python/cpython/blob/3.14/Lib/test/test_typing.py#L4373 And the current allow list: https://github.com/python/cpython/blob/main/Lib/typing.py#L1894
Discovered through CPython 3.12 test_typing.py: https://github.com/JanEricNitschke/typing_extensions/actions/runs/17639167194/job/50121940225#step:7:36 Tests are from here: - https://github.com/python/cpython/pull/27545 - https://github.com/python/cpython/pull/28121 - https://github.com/python/cpython/pull/28121 Code is from current CPython: - https://github.com/python/cpython/blob/main/Lib/typing.py#L1843 - https://github.com/python/cpython/blob/main/Lib/typing.py#L2121
Fixes #636, backport of https://github.com/python/cpython/pull/137281 Added some inline comments about the implementation below.
According to git blame, `TypeAlias` was added in https://github.com/python/typing_extensions/commit/d362ccb6504bf52618796822e8e6ffa9091575a4, which GitHub's UI indicates was included as early as 3.10.0.0
Currently, both `typing.get_type_hints` and `typing_extensions.get_type_hints` fail on a lone stringified `ClassVar` annotation in Python 3.9 and 3.10: ```python from __future__ import annotations from typing import ClassVar, get_type_hints as get_type_hints from...
This is very similar to https://github.com/python/cpython/issues/137191, but with a slightly different error message: ```py from typing_extensions import Generic, Protocol, TypeVar T1 = TypeVar("T1") T2 = TypeVar("T2", default=object) class A(Protocol[T1]): ......
My attempt at implementing [PEP 661](https://peps.python.org/pep-0661/) since I was unhappy with #594. I'm hoping that this is a PR of decent quality and not just me desperately wanting pickle support....