Skip to content

Commit 07c09a4

Browse files
Update typing-extensions to 4.14.0rc1 (#14139)
Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 57cb510 commit 07c09a4

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ stubdefaulter==0.1.0; python_version < "3.14"
2323
termcolor>=2.3
2424
tomli==2.2.1
2525
tomlkit==0.13.2
26-
typing_extensions>=4.13.0rc1
26+
typing_extensions>=4.14.0rc1
2727
uv==0.7.4
2828

2929
# Utilities for typeshed infrastructure scripts.

stdlib/@tests/stubtest_allowlists/py310.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protoco
7777
builtins.float.__setformat__ # Internal method for CPython test suite
7878
typing._SpecialForm.__mro_entries__ # Exists at runtime, but missing from stubs
7979

80+
# Will always raise. Not included to avoid type checkers inferring that
81+
# Sentinel instances are callable.
82+
typing_extensions.Sentinel.__call__
83+
8084

8185
# =======
8286
# <= 3.10

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ typing(_extensions)?\.IO\.writelines
169169
.*\.ForwardRef\.__stringifier_dict__
170170

171171
# These protocols use ABC hackery at runtime.
172-
io.Reader.__class_getitem__
173-
io.Reader.read
174-
io.Writer.__class_getitem__
175-
io.Writer.write
172+
(io|typing_extensions)\.Reader\.__class_getitem__
173+
(io|typing_extensions)\.Reader\.read
174+
(io|typing_extensions)\.Writer\.__class_getitem__
175+
(io|typing_extensions)\.Writer\.write
176176

177177

178178
# =============================================================

stdlib/@tests/stubtest_allowlists/py39.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ tempfile.SpooledTemporaryFile.writable
4444

4545
tkinter.Tk.split # Exists at runtime, but missing from stubs
4646

47+
# Will always raise. Not included to avoid type checkers inferring that
48+
# Sentinel instances are callable.
49+
typing_extensions.Sentinel.__call__
50+
4751

4852
# =======
4953
# <= 3.11

stdlib/typing_extensions.pyi

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ __all__ = [
110110
"SupportsIndex",
111111
"SupportsInt",
112112
"SupportsRound",
113+
"Reader",
114+
"Writer",
113115
# One-off things.
114116
"Annotated",
115117
"assert_never",
@@ -136,6 +138,7 @@ __all__ = [
136138
"overload",
137139
"override",
138140
"Protocol",
141+
"Sentinel",
139142
"reveal_type",
140143
"runtime",
141144
"runtime_checkable",
@@ -199,6 +202,7 @@ _T = _TypeVar("_T")
199202
_F = _TypeVar("_F", bound=Callable[..., Any])
200203
_TC = _TypeVar("_TC", bound=type[object])
201204
_T_co = _TypeVar("_T_co", covariant=True) # Any type covariant containers.
205+
_T_contra = _TypeVar("_T_contra", contravariant=True)
202206

203207
class _Final: ... # This should be imported from typing but that breaks pytype
204208

@@ -446,6 +450,19 @@ else:
446450
@abc.abstractmethod
447451
def __round__(self, ndigits: int, /) -> _T_co: ...
448452

453+
if sys.version_info >= (3, 14):
454+
from io import Reader as Reader, Writer as Writer
455+
else:
456+
@runtime_checkable
457+
class Reader(Protocol[_T_co]):
458+
@abc.abstractmethod
459+
def read(self, size: int = ..., /) -> _T_co: ...
460+
461+
@runtime_checkable
462+
class Writer(Protocol[_T_contra]):
463+
@abc.abstractmethod
464+
def write(self, data: _T_contra, /) -> int: ...
465+
449466
if sys.version_info >= (3, 13):
450467
from types import CapsuleType as CapsuleType
451468
from typing import (
@@ -670,6 +687,16 @@ else:
670687
globals: Mapping[str, Any] | None = None, # value types depend on the key
671688
locals: Mapping[str, Any] | None = None, # value types depend on the key
672689
type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None,
673-
format: Format = Format.VALUE, # noqa: Y011
690+
format: Format | None = None,
674691
_recursive_guard: Container[str] = ...,
675692
) -> AnnotationForm: ...
693+
694+
# PEP 661
695+
class Sentinel:
696+
def __init__(self, name: str, repr: str | None = None) -> None: ...
697+
if sys.version_info >= (3, 14):
698+
def __or__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions
699+
def __ror__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions
700+
else:
701+
def __or__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions
702+
def __ror__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions

0 commit comments

Comments
 (0)