mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-06-23 17:28:38 +08:00
Update typing_extensions to 4.13.0rc1 (#13671)
Also sort __all__ to match the implementation
This commit is contained in:
@@ -18,7 +18,7 @@ stubdefaulter==0.1.0
|
||||
termcolor>=2.3
|
||||
tomli==2.2.1
|
||||
tomlkit==0.13.2
|
||||
typing_extensions>=4.12.0rc1
|
||||
typing_extensions>=4.13.0rc1
|
||||
uv==0.5.14
|
||||
|
||||
# Utilities for typeshed infrastructure scripts.
|
||||
|
||||
@@ -501,8 +501,9 @@ typing(_extensions)?\.ValuesView
|
||||
typing_extensions\.Final
|
||||
typing_extensions\.LiteralString
|
||||
|
||||
typing._SpecialForm.__call__ # Typing-related weirdness
|
||||
typing._SpecialForm.__init__ # Typing-related weirdness
|
||||
# Typing-related weirdness
|
||||
typing._SpecialForm.__call__
|
||||
typing._SpecialForm.__init__
|
||||
|
||||
# These are abstract properties at runtime,
|
||||
# but marking them as such in the stub breaks half the the typed-Python ecosystem (see #8726)
|
||||
@@ -525,6 +526,10 @@ typing(_extensions)?\.(Async)?ContextManager
|
||||
typing(_extensions)?\.IO\.__iter__
|
||||
typing(_extensions)?\.IO\.__next__
|
||||
|
||||
# Will always raise. Not included to avoid type checkers inferring that
|
||||
# TypeAliasType instances are callable.
|
||||
typing_extensions.TypeAliasType.__call__
|
||||
|
||||
types.MethodType.__closure__ # read-only but not actually a property; stubtest thinks it doesn't exist.
|
||||
types.MethodType.__code__ # read-only but not actually a property; stubtest thinks it doesn't exist.
|
||||
types.MethodType.__defaults__ # read-only but not actually a property; stubtest thinks it doesn't exist.
|
||||
|
||||
@@ -240,9 +240,6 @@ poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
|
||||
tkinter.test # Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
tkinter\.test\..+ # Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
|
||||
# Exist at runtime for internal reasons, no need to put them in the stub
|
||||
typing_extensions\.TypeAliasType\.__call__
|
||||
typing_extensions\.TypeAliasType\.__init_subclass__
|
||||
# We call them read-only properties, runtime implementation is slightly different
|
||||
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
|
||||
|
||||
|
||||
@@ -204,9 +204,6 @@ poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
|
||||
tkinter.test # Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
tkinter\.test\..+ # Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
|
||||
# Exist at runtime for internal reasons, no need to put them in the stub
|
||||
typing_extensions\.TypeAliasType\.__call__
|
||||
typing_extensions\.TypeAliasType\.__init_subclass__
|
||||
# We call them read-only properties, runtime implementation is slightly different
|
||||
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
zoneinfo.ZoneInfo.from_file # Pos-only parameters had different "names" in different Python versions
|
||||
|
||||
# Initialized at runtime
|
||||
typing_extensions.TypeAliasType.__parameters__
|
||||
typing_extensions.TypeAliasType.__value__
|
||||
|
||||
|
||||
# ====================================
|
||||
# Pre-existing errors from Python 3.11
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
zoneinfo.ZoneInfo.from_file # Pos-only parameters had different "names" in different Python versions
|
||||
|
||||
# Initialized at runtime
|
||||
typing_extensions.TypeAliasType.__parameters__
|
||||
typing_extensions.TypeAliasType.__value__
|
||||
|
||||
|
||||
# =======
|
||||
# >= 3.11
|
||||
|
||||
@@ -213,9 +213,6 @@ poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
|
||||
tkinter.test # Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
tkinter\.test\..+ # Modules that exist at runtime, but shouldn't be added to typeshed
|
||||
|
||||
# Exist at runtime for internal reasons, no need to put them in the stub
|
||||
typing_extensions\.TypeAliasType\.__call__
|
||||
typing_extensions\.TypeAliasType\.__init_subclass__
|
||||
# We call them read-only properties, runtime implementation is slightly different
|
||||
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
|
||||
|
||||
|
||||
+4
-4
@@ -345,12 +345,12 @@ class Signature:
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
def get_annotations(
|
||||
obj: Callable[..., object] | type[Any] | ModuleType,
|
||||
obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module
|
||||
*,
|
||||
globals: Mapping[str, Any] | None = None,
|
||||
locals: Mapping[str, Any] | None = None,
|
||||
globals: Mapping[str, Any] | None = None, # value types depend on the key
|
||||
locals: Mapping[str, Any] | None = None, # value types depend on the key
|
||||
eval_str: bool = False,
|
||||
) -> dict[str, Any]: ...
|
||||
) -> dict[str, Any]: ... # values are type expressions
|
||||
|
||||
# The name is the same as the enum's name in CPython
|
||||
class _ParameterKind(enum.IntEnum):
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import abc
|
||||
import enum
|
||||
import sys
|
||||
import typing
|
||||
from _collections_abc import dict_items, dict_keys, dict_values
|
||||
from _typeshed import IdentityFunction
|
||||
from _typeshed import IdentityFunction, Incomplete, Unused
|
||||
from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager
|
||||
from types import ModuleType
|
||||
from typing import ( # noqa: Y022,Y037,Y038,Y039
|
||||
IO as IO,
|
||||
TYPE_CHECKING as TYPE_CHECKING,
|
||||
@@ -68,9 +70,10 @@ if sys.version_info >= (3, 10):
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
# Please keep order the same as at runtime.
|
||||
__all__ = [
|
||||
# Super-special typing primitives.
|
||||
"Any",
|
||||
"Buffer",
|
||||
"ClassVar",
|
||||
"Concatenate",
|
||||
"Final",
|
||||
@@ -83,14 +86,16 @@ __all__ = [
|
||||
"TypeVar",
|
||||
"TypeVarTuple",
|
||||
"Unpack",
|
||||
# ABCs (from collections.abc).
|
||||
"Awaitable",
|
||||
"AsyncIterator",
|
||||
"AsyncIterable",
|
||||
"Coroutine",
|
||||
"AsyncGenerator",
|
||||
"AsyncContextManager",
|
||||
"CapsuleType",
|
||||
"Buffer",
|
||||
"ChainMap",
|
||||
# Concrete collection types.
|
||||
"ContextManager",
|
||||
"Counter",
|
||||
"Deque",
|
||||
@@ -98,20 +103,34 @@ __all__ = [
|
||||
"NamedTuple",
|
||||
"OrderedDict",
|
||||
"TypedDict",
|
||||
"SupportsIndex",
|
||||
# Structural checks, a.k.a. protocols.
|
||||
"SupportsAbs",
|
||||
"SupportsRound",
|
||||
"SupportsBytes",
|
||||
"SupportsComplex",
|
||||
"SupportsFloat",
|
||||
"SupportsIndex",
|
||||
"SupportsInt",
|
||||
"SupportsRound",
|
||||
# One-off things.
|
||||
"Annotated",
|
||||
"assert_never",
|
||||
"assert_type",
|
||||
"clear_overloads",
|
||||
"dataclass_transform",
|
||||
"deprecated",
|
||||
"Doc",
|
||||
"evaluate_forward_ref",
|
||||
"get_overloads",
|
||||
"final",
|
||||
"Format",
|
||||
"get_annotations",
|
||||
"get_args",
|
||||
"get_origin",
|
||||
"get_original_bases",
|
||||
"get_protocol_members",
|
||||
"get_type_hints",
|
||||
"IntVar",
|
||||
"is_protocol",
|
||||
"is_typeddict",
|
||||
"Literal",
|
||||
"NewType",
|
||||
@@ -124,18 +143,18 @@ __all__ = [
|
||||
"Text",
|
||||
"TypeAlias",
|
||||
"TypeAliasType",
|
||||
"TypeForm",
|
||||
"TypeGuard",
|
||||
"TypeIs",
|
||||
"TYPE_CHECKING",
|
||||
"Never",
|
||||
"NoReturn",
|
||||
"ReadOnly",
|
||||
"Required",
|
||||
"NotRequired",
|
||||
"clear_overloads",
|
||||
"get_args",
|
||||
"get_origin",
|
||||
"get_original_bases",
|
||||
"get_overloads",
|
||||
"get_type_hints",
|
||||
"NoDefault",
|
||||
"NoExtraItems",
|
||||
# Pure aliases, have always been in typing
|
||||
"AbstractSet",
|
||||
"AnyStr",
|
||||
"BinaryIO",
|
||||
@@ -143,7 +162,6 @@ __all__ = [
|
||||
"Collection",
|
||||
"Container",
|
||||
"Dict",
|
||||
"Doc",
|
||||
"ForwardRef",
|
||||
"FrozenSet",
|
||||
"Generator",
|
||||
@@ -161,7 +179,6 @@ __all__ = [
|
||||
"MutableMapping",
|
||||
"MutableSequence",
|
||||
"MutableSet",
|
||||
"NoDefault",
|
||||
"Optional",
|
||||
"Pattern",
|
||||
"Reversible",
|
||||
@@ -173,12 +190,10 @@ __all__ = [
|
||||
"Union",
|
||||
"ValuesView",
|
||||
"cast",
|
||||
"get_protocol_members",
|
||||
"is_protocol",
|
||||
"no_type_check",
|
||||
"no_type_check_decorator",
|
||||
"ReadOnly",
|
||||
"TypeIs",
|
||||
# Added dynamically
|
||||
"CapsuleType",
|
||||
]
|
||||
|
||||
_T = typing.TypeVar("_T")
|
||||
@@ -382,33 +397,11 @@ if sys.version_info >= (3, 12):
|
||||
SupportsIndex as SupportsIndex,
|
||||
SupportsInt as SupportsInt,
|
||||
SupportsRound as SupportsRound,
|
||||
TypeAliasType as TypeAliasType,
|
||||
override as override,
|
||||
)
|
||||
else:
|
||||
def override(arg: _F, /) -> _F: ...
|
||||
def get_original_bases(cls: type, /) -> tuple[Any, ...]: ...
|
||||
@final
|
||||
class TypeAliasType:
|
||||
def __init__(
|
||||
self, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()
|
||||
) -> None: ...
|
||||
@property
|
||||
def __value__(self) -> Any: ...
|
||||
@property
|
||||
def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ...
|
||||
@property
|
||||
def __parameters__(self) -> tuple[Any, ...]: ...
|
||||
@property
|
||||
def __name__(self) -> str: ...
|
||||
# It's writable on types, but not on instances of TypeAliasType.
|
||||
@property
|
||||
def __module__(self) -> str | None: ... # type: ignore[override]
|
||||
# Returns typing._GenericAlias, which isn't stubbed.
|
||||
def __getitem__(self, parameters: Any) -> Any: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
def __or__(self, right: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, left: Any) -> _SpecialForm: ...
|
||||
|
||||
# mypy and pyright object to this being both ABC and Protocol.
|
||||
# At runtime it inherits from ABC and is not a Protocol, but it is on the
|
||||
@@ -569,8 +562,71 @@ else:
|
||||
ReadOnly: _SpecialForm
|
||||
TypeIs: _SpecialForm
|
||||
|
||||
# TypeAliasType was added in Python 3.12, but had significant changes in 3.14.
|
||||
if sys.version_info >= (3, 14):
|
||||
from typing import TypeAliasType as TypeAliasType
|
||||
else:
|
||||
@final
|
||||
class TypeAliasType:
|
||||
def __init__(
|
||||
self, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()
|
||||
) -> None: ... # value is a type expression
|
||||
@property
|
||||
def __value__(self) -> Any: ... # a type expression
|
||||
@property
|
||||
def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ...
|
||||
@property
|
||||
# `__parameters__` can include special forms if a `TypeVarTuple` was
|
||||
# passed as a `type_params` element to the constructor method.
|
||||
def __parameters__(self) -> tuple[TypeVar | ParamSpec | Any, ...]: ...
|
||||
@property
|
||||
def __name__(self) -> str: ...
|
||||
# It's writable on types, but not on instances of TypeAliasType.
|
||||
@property
|
||||
def __module__(self) -> str | None: ... # type: ignore[override]
|
||||
# Returns typing._GenericAlias, which isn't stubbed.
|
||||
def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> Any: ...
|
||||
def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
def __or__(self, right: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, left: Any) -> _SpecialForm: ...
|
||||
|
||||
# PEP 727
|
||||
class Doc:
|
||||
documentation: str
|
||||
def __init__(self, documentation: str, /) -> None: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
|
||||
# PEP 728
|
||||
class _NoExtraItemsType: ...
|
||||
|
||||
NoExtraItems: _NoExtraItemsType
|
||||
|
||||
# PEP 747
|
||||
TypeForm: _SpecialForm
|
||||
|
||||
class Format(enum.IntEnum):
|
||||
VALUE = 1
|
||||
FORWARDREF = 2
|
||||
STRING = 3
|
||||
|
||||
# PEP 649/749
|
||||
def get_annotations(
|
||||
obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module
|
||||
*,
|
||||
globals: Mapping[str, Any] | None = None, # value types depend on the key
|
||||
locals: Mapping[str, Any] | None = None, # value types depend on the key
|
||||
eval_str: bool = False,
|
||||
format: Format = Format.VALUE, # noqa: Y011
|
||||
) -> dict[str, Any]: ... # values are type expressions
|
||||
def evaluate_forward_ref(
|
||||
forward_ref: ForwardRef,
|
||||
*,
|
||||
owner: Callable[..., object] | type[object] | ModuleType | None = None, # any callable, class, or module
|
||||
globals: Mapping[str, Any] | None = None, # value types depend on the key
|
||||
locals: Mapping[str, Any] | None = None, # value types depend on the key
|
||||
type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None,
|
||||
format: Format = Format.VALUE, # noqa: Y011
|
||||
_recursive_guard: Container[str] = ...,
|
||||
) -> Any: ... # str if format is Format.STRING, otherwise a type expression
|
||||
|
||||
Reference in New Issue
Block a user