From 2985ef414c0266c9fe05561010050b1aa283ff91 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 May 2024 15:16:15 -0400 Subject: [PATCH] `typing(_extensions)` updates for py313 (#12030) --- stdlib/@tests/stubtest_allowlists/py313.txt | 10 +--------- stdlib/typing.pyi | 16 ++++++++++++++-- stdlib/typing_extensions.pyi | 8 +++++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 4729d14ba..322c480fd 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -232,15 +232,6 @@ turtle.settiltangle types.CodeType.__replace__ types.MappingProxyType.get types.SimpleNamespace.__replace__ -typing.ForwardRef._evaluate -typing.ReadOnly -typing.TypeIs -typing.TypeVar.__typing_prepare_subst__ -typing.__all__ -typing_extensions.ForwardRef._evaluate -typing_extensions.Protocol -typing_extensions.ReadOnly -typing_extensions.TypeIs unittest.IsolatedAsyncioTestCase.loop_factory unittest.TestProgram.usageExit unittest.__all__ @@ -381,6 +372,7 @@ importlib.metadata.DeprecatedNonAbstract.__new__ typing\._SpecialForm.* typing\.NamedTuple typing\.LiteralString +typing_extensions.Protocol # These only exist to give a better error message if you try to subclass an instance typing.ParamSpec.__mro_entries__ diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 1b021d1ee..f04b2d858 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -129,7 +129,7 @@ if sys.version_info >= (3, 12): __all__ += ["TypeAliasType", "override"] if sys.version_info >= (3, 13): - __all__ += ["get_protocol_members", "is_protocol", "NoDefault"] + __all__ += ["get_protocol_members", "is_protocol", "NoDefault", "TypeIs", "ReadOnly"] Any = object() @@ -183,6 +183,7 @@ class TypeVar: if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any) -> Any: ... if sys.version_info >= (3, 13): + def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... def has_default(self) -> bool: ... # Used for an undocumented mypy feature. Does not exist at runtime. @@ -989,7 +990,16 @@ class ForwardRef: else: def __init__(self, arg: str, is_argument: bool = True) -> None: ... - if sys.version_info >= (3, 9): + if sys.version_info >= (3, 13): + def _evaluate( + self, + globalns: dict[str, Any] | None, + localns: dict[str, Any] | None, + type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ..., + *, + recursive_guard: frozenset[str], + ) -> Any | None: ... + elif sys.version_info >= (3, 9): def _evaluate( self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None, recursive_guard: frozenset[str] ) -> Any | None: ... @@ -1036,3 +1046,5 @@ if sys.version_info >= (3, 13): class _NoDefaultType: ... NoDefault: _NoDefaultType + TypeIs: _SpecialForm + ReadOnly: _SpecialForm diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 73fd2dc8c..a7d2b2c2e 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -419,6 +419,8 @@ if sys.version_info >= (3, 13): from typing import ( NoDefault as NoDefault, ParamSpec as ParamSpec, + ReadOnly as ReadOnly, + TypeIs as TypeIs, TypeVar as TypeVar, TypeVarTuple as TypeVarTuple, get_protocol_members as get_protocol_members, @@ -520,11 +522,11 @@ else: def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... + ReadOnly: _SpecialForm + TypeIs: _SpecialForm + class Doc: documentation: str def __init__(self, documentation: str, /) -> None: ... def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... - -ReadOnly: _SpecialForm -TypeIs: _SpecialForm