mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-09 06:46:18 +08:00
Drop Python 3.8 support in typing[_extensions] and types (#13763)
This commit is contained in:
@@ -4,11 +4,9 @@ This tests that star imports work when using "all += " syntax.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from typing import *
|
||||
from zipfile import *
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
x: Annotated[int, 42]
|
||||
x: Annotated[int, 42]
|
||||
|
||||
p: Path
|
||||
|
||||
+26
-31
@@ -47,11 +47,9 @@ __all__ = [
|
||||
"WrapperDescriptorType",
|
||||
"resolve_bases",
|
||||
"CellType",
|
||||
"GenericAlias",
|
||||
]
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ += ["GenericAlias"]
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
__all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"]
|
||||
|
||||
@@ -320,11 +318,10 @@ class MappingProxyType(Mapping[_KT, _VT_co]):
|
||||
def get(self, key: _KT, /) -> _VT_co | None: ...
|
||||
@overload
|
||||
def get(self, key: _KT, default: _VT_co | _T2, /) -> _VT_co | _T2: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
|
||||
def __reversed__(self) -> Iterator[_KT]: ...
|
||||
def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
|
||||
def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
|
||||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
|
||||
def __reversed__(self) -> Iterator[_KT]: ...
|
||||
def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
|
||||
def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
|
||||
|
||||
class SimpleNamespace:
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
@@ -425,8 +422,7 @@ class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
|
||||
@overload
|
||||
async def athrow(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
|
||||
def aclose(self) -> Coroutine[Any, Any, None]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
|
||||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
|
||||
|
||||
@final
|
||||
class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
|
||||
@@ -647,30 +643,29 @@ def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Await
|
||||
@overload
|
||||
def coroutine(func: _Fn) -> _Fn: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
class GenericAlias:
|
||||
class GenericAlias:
|
||||
@property
|
||||
def __origin__(self) -> type | TypeAliasType: ...
|
||||
@property
|
||||
def __args__(self) -> tuple[Any, ...]: ...
|
||||
@property
|
||||
def __parameters__(self) -> tuple[Any, ...]: ...
|
||||
def __new__(cls, origin: type, args: Any, /) -> Self: ...
|
||||
def __getitem__(self, typeargs: Any, /) -> GenericAlias: ...
|
||||
def __eq__(self, value: object, /) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __mro_entries__(self, bases: Iterable[object], /) -> tuple[type, ...]: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
@property
|
||||
def __origin__(self) -> type | TypeAliasType: ...
|
||||
def __unpacked__(self) -> bool: ...
|
||||
@property
|
||||
def __args__(self) -> tuple[Any, ...]: ...
|
||||
@property
|
||||
def __parameters__(self) -> tuple[Any, ...]: ...
|
||||
def __new__(cls, origin: type, args: Any, /) -> Self: ...
|
||||
def __getitem__(self, typeargs: Any, /) -> GenericAlias: ...
|
||||
def __eq__(self, value: object, /) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __mro_entries__(self, bases: Iterable[object], /) -> tuple[type, ...]: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
@property
|
||||
def __unpacked__(self) -> bool: ...
|
||||
@property
|
||||
def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
def __or__(self, value: Any, /) -> UnionType: ...
|
||||
def __ror__(self, value: Any, /) -> UnionType: ...
|
||||
def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
def __or__(self, value: Any, /) -> UnionType: ...
|
||||
def __ror__(self, value: Any, /) -> UnionType: ...
|
||||
|
||||
# GenericAlias delegates attr access to `__origin__`
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
# GenericAlias delegates attr access to `__origin__`
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
@final
|
||||
|
||||
+36
-57
@@ -13,6 +13,7 @@ from types import (
|
||||
BuiltinFunctionType,
|
||||
CodeType,
|
||||
FunctionType,
|
||||
GenericAlias,
|
||||
MethodDescriptorType,
|
||||
MethodType,
|
||||
MethodWrapperType,
|
||||
@@ -22,13 +23,12 @@ from types import (
|
||||
)
|
||||
from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, deprecated
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
if sys.version_info >= (3, 10):
|
||||
from types import UnionType
|
||||
|
||||
__all__ = [
|
||||
"AbstractSet",
|
||||
"Annotated",
|
||||
"Any",
|
||||
"AnyStr",
|
||||
"AsyncContextManager",
|
||||
@@ -36,6 +36,7 @@ __all__ = [
|
||||
"AsyncIterable",
|
||||
"AsyncIterator",
|
||||
"Awaitable",
|
||||
"BinaryIO",
|
||||
"ByteString",
|
||||
"Callable",
|
||||
"ChainMap",
|
||||
@@ -49,10 +50,12 @@ __all__ = [
|
||||
"Deque",
|
||||
"Dict",
|
||||
"Final",
|
||||
"ForwardRef",
|
||||
"FrozenSet",
|
||||
"Generator",
|
||||
"Generic",
|
||||
"Hashable",
|
||||
"IO",
|
||||
"ItemsView",
|
||||
"Iterable",
|
||||
"Iterator",
|
||||
@@ -61,12 +64,16 @@ __all__ = [
|
||||
"Literal",
|
||||
"Mapping",
|
||||
"MappingView",
|
||||
"Match",
|
||||
"MutableMapping",
|
||||
"MutableSequence",
|
||||
"MutableSet",
|
||||
"NamedTuple",
|
||||
"NewType",
|
||||
"NoReturn",
|
||||
"Optional",
|
||||
"OrderedDict",
|
||||
"Pattern",
|
||||
"Protocol",
|
||||
"Reversible",
|
||||
"Sequence",
|
||||
@@ -80,6 +87,7 @@ __all__ = [
|
||||
"SupportsInt",
|
||||
"SupportsRound",
|
||||
"Text",
|
||||
"TextIO",
|
||||
"Tuple",
|
||||
"Type",
|
||||
"TypeVar",
|
||||
@@ -96,14 +104,8 @@ __all__ = [
|
||||
"no_type_check_decorator",
|
||||
"overload",
|
||||
"runtime_checkable",
|
||||
"ForwardRef",
|
||||
"NoReturn",
|
||||
"OrderedDict",
|
||||
]
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ += ["Annotated", "BinaryIO", "IO", "Match", "Pattern", "TextIO"]
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
__all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"]
|
||||
|
||||
@@ -203,7 +205,6 @@ class _SpecialForm(_Final):
|
||||
|
||||
Union: _SpecialForm
|
||||
Generic: _SpecialForm
|
||||
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
|
||||
Protocol: _SpecialForm
|
||||
Callable: _SpecialForm
|
||||
Type: _SpecialForm
|
||||
@@ -386,8 +387,7 @@ ChainMap = _Alias()
|
||||
|
||||
OrderedDict = _Alias()
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
Annotated: _SpecialForm
|
||||
Annotated: _SpecialForm
|
||||
|
||||
# Predefined type variables.
|
||||
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001
|
||||
@@ -858,19 +858,12 @@ _get_type_hints_obj_allowed_types: typing_extensions.TypeAlias = ( # noqa: Y042
|
||||
| MethodDescriptorType
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def get_type_hints(
|
||||
obj: _get_type_hints_obj_allowed_types,
|
||||
globalns: dict[str, Any] | None = None,
|
||||
localns: Mapping[str, Any] | None = None,
|
||||
include_extras: bool = False,
|
||||
) -> dict[str, Any]: ...
|
||||
|
||||
else:
|
||||
def get_type_hints(
|
||||
obj: _get_type_hints_obj_allowed_types, globalns: dict[str, Any] | None = None, localns: Mapping[str, Any] | None = None
|
||||
) -> dict[str, Any]: ...
|
||||
|
||||
def get_type_hints(
|
||||
obj: _get_type_hints_obj_allowed_types,
|
||||
globalns: dict[str, Any] | None = None,
|
||||
localns: Mapping[str, Any] | None = None,
|
||||
include_extras: bool = False,
|
||||
) -> dict[str, Any]: ...
|
||||
def get_args(tp: Any) -> tuple[Any, ...]: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
@@ -879,15 +872,10 @@ if sys.version_info >= (3, 10):
|
||||
@overload
|
||||
def get_origin(tp: UnionType) -> type[UnionType]: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@overload
|
||||
def get_origin(tp: GenericAlias) -> type: ...
|
||||
@overload
|
||||
def get_origin(tp: Any) -> Any | None: ...
|
||||
|
||||
else:
|
||||
def get_origin(tp: Any) -> Any | None: ...
|
||||
|
||||
@overload
|
||||
def get_origin(tp: GenericAlias) -> type: ...
|
||||
@overload
|
||||
def get_origin(tp: Any) -> Any | None: ...
|
||||
@overload
|
||||
def cast(typ: type[_T], val: Any) -> _T: ...
|
||||
@overload
|
||||
@@ -914,8 +902,6 @@ if sys.version_info >= (3, 11):
|
||||
# Type constructors
|
||||
|
||||
class NamedTuple(tuple[Any, ...]):
|
||||
if sys.version_info < (3, 9):
|
||||
_field_types: ClassVar[dict[str, type]]
|
||||
_field_defaults: ClassVar[dict[str, Any]]
|
||||
_fields: ClassVar[tuple[str, ...]]
|
||||
# __orig_bases__ sometimes exists on <3.12, but not consistently
|
||||
@@ -942,9 +928,8 @@ class NamedTuple(tuple[Any, ...]):
|
||||
@type_check_only
|
||||
class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
__total__: ClassVar[bool]
|
||||
if sys.version_info >= (3, 9):
|
||||
__required_keys__: ClassVar[frozenset[str]]
|
||||
__optional_keys__: ClassVar[frozenset[str]]
|
||||
__required_keys__: ClassVar[frozenset[str]]
|
||||
__optional_keys__: ClassVar[frozenset[str]]
|
||||
# __orig_bases__ sometimes exists on <3.12, but not consistently,
|
||||
# so we only add it to the stub on 3.12+
|
||||
if sys.version_info >= (3, 12):
|
||||
@@ -964,17 +949,16 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
def items(self) -> dict_items[str, object]: ...
|
||||
def keys(self) -> dict_keys[str, object]: ...
|
||||
def values(self) -> dict_values[str, object]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
@overload
|
||||
def __or__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ...
|
||||
@overload
|
||||
def __or__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
@overload
|
||||
def __ror__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ...
|
||||
@overload
|
||||
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
# supposedly incompatible definitions of __or__ and __ior__
|
||||
def __ior__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ... # type: ignore[misc]
|
||||
@overload
|
||||
def __or__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ...
|
||||
@overload
|
||||
def __or__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
@overload
|
||||
def __ror__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ...
|
||||
@overload
|
||||
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
# supposedly incompatible definitions of __or__ and __ior__
|
||||
def __ior__(self, value: typing_extensions.Self, /) -> typing_extensions.Self: ... # type: ignore[misc]
|
||||
|
||||
@final
|
||||
class ForwardRef(_Final):
|
||||
@@ -985,11 +969,8 @@ class ForwardRef(_Final):
|
||||
__forward_is_argument__: bool
|
||||
__forward_is_class__: bool
|
||||
__forward_module__: Any | None
|
||||
if sys.version_info >= (3, 9):
|
||||
# The module and is_class arguments were added in later Python 3.9 versions.
|
||||
def __init__(self, arg: str, is_argument: bool = True, module: Any | None = None, *, is_class: bool = False) -> None: ...
|
||||
else:
|
||||
def __init__(self, arg: str, is_argument: bool = True) -> None: ...
|
||||
|
||||
def __init__(self, arg: str, is_argument: bool = True, module: Any | None = None, *, is_class: bool = False) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 13):
|
||||
@overload
|
||||
@@ -1019,12 +1000,10 @@ class ForwardRef(_Final):
|
||||
*,
|
||||
recursive_guard: frozenset[str],
|
||||
) -> Any | None: ...
|
||||
elif sys.version_info >= (3, 9):
|
||||
else:
|
||||
def _evaluate(
|
||||
self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, recursive_guard: frozenset[str]
|
||||
) -> Any | None: ...
|
||||
else:
|
||||
def _evaluate(self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None) -> Any | None: ...
|
||||
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ import typing
|
||||
from _collections_abc import dict_items, dict_keys, dict_values
|
||||
from _typeshed import IdentityFunction, Incomplete, Unused
|
||||
from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager
|
||||
from types import ModuleType
|
||||
from types import GenericAlias, ModuleType
|
||||
from typing import ( # noqa: Y022,Y037,Y038,Y039
|
||||
IO as IO,
|
||||
TYPE_CHECKING as TYPE_CHECKING,
|
||||
@@ -67,8 +67,6 @@ from typing import ( # noqa: Y022,Y037,Y038,Y039
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
from types import UnionType
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
# Please keep order the same as at runtime.
|
||||
__all__ = [
|
||||
@@ -254,18 +252,17 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
def keys(self) -> dict_keys[str, object]: ...
|
||||
def values(self) -> dict_values[str, object]: ...
|
||||
def __delitem__(self, k: Never) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
@overload
|
||||
def __or__(self, value: Self, /) -> Self: ...
|
||||
@overload
|
||||
def __or__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
@overload
|
||||
def __ror__(self, value: Self, /) -> Self: ...
|
||||
@overload
|
||||
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
# supposedly incompatible definitions of `__ior__` and `__or__`:
|
||||
# Since this module defines "Self" it is not recognized by Ruff as typing_extensions.Self
|
||||
def __ior__(self, value: Self, /) -> Self: ... # type: ignore[misc]
|
||||
@overload
|
||||
def __or__(self, value: Self, /) -> Self: ...
|
||||
@overload
|
||||
def __or__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
@overload
|
||||
def __ror__(self, value: Self, /) -> Self: ...
|
||||
@overload
|
||||
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
# supposedly incompatible definitions of `__ior__` and `__or__`:
|
||||
# Since this module defines "Self" it is not recognized by Ruff as typing_extensions.Self
|
||||
def __ior__(self, value: Self, /) -> Self: ... # type: ignore[misc]
|
||||
|
||||
OrderedDict = _Alias()
|
||||
|
||||
@@ -281,10 +278,8 @@ if sys.version_info >= (3, 10):
|
||||
@overload
|
||||
def get_origin(tp: UnionType) -> type[UnionType]: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@overload
|
||||
def get_origin(tp: GenericAlias) -> type: ...
|
||||
|
||||
@overload
|
||||
def get_origin(tp: GenericAlias) -> type: ...
|
||||
@overload
|
||||
def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ...
|
||||
@overload
|
||||
@@ -364,8 +359,6 @@ else:
|
||||
) -> IdentityFunction: ...
|
||||
|
||||
class NamedTuple(tuple[Any, ...]):
|
||||
if sys.version_info < (3, 9):
|
||||
_field_types: ClassVar[dict[str, type]]
|
||||
_field_defaults: ClassVar[dict[str, Any]]
|
||||
_fields: ClassVar[tuple[str, ...]]
|
||||
__orig_bases__: ClassVar[tuple[Any, ...]]
|
||||
|
||||
Reference in New Issue
Block a user