Remove Python 3.7 branches (#11238)

This commit is contained in:
Sebastian Rittau
2024-01-05 11:39:39 +01:00
committed by GitHub
parent 4e62577002
commit 23604858a6
122 changed files with 1952 additions and 3800 deletions

View File

@@ -1,4 +1,6 @@
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
# TODO: The collections import is required, otherwise mypy crashes.
# https://github.com/python/mypy/issues/16744
import collections # noqa: F401 # pyright: ignore
import sys
import typing_extensions
from _collections_abc import dict_items, dict_keys, dict_values
@@ -46,6 +48,7 @@ __all__ = [
"DefaultDict",
"Deque",
"Dict",
"Final",
"FrozenSet",
"Generator",
"Generic",
@@ -55,6 +58,7 @@ __all__ = [
"Iterator",
"KeysView",
"List",
"Literal",
"Mapping",
"MappingView",
"MutableMapping",
@@ -63,6 +67,7 @@ __all__ = [
"NamedTuple",
"NewType",
"Optional",
"Protocol",
"Reversible",
"Sequence",
"Set",
@@ -71,38 +76,31 @@ __all__ = [
"SupportsBytes",
"SupportsComplex",
"SupportsFloat",
"SupportsIndex",
"SupportsInt",
"SupportsRound",
"Text",
"Tuple",
"Type",
"TypeVar",
"TypedDict",
"Union",
"ValuesView",
"TYPE_CHECKING",
"cast",
"final",
"get_args",
"get_origin",
"get_type_hints",
"no_type_check",
"no_type_check_decorator",
"overload",
"runtime_checkable",
"ForwardRef",
"NoReturn",
"OrderedDict",
]
if sys.version_info >= (3, 8):
__all__ += [
"Final",
"Literal",
"Protocol",
"SupportsIndex",
"TypedDict",
"final",
"get_args",
"get_origin",
"runtime_checkable",
]
if sys.version_info >= (3, 9):
__all__ += ["Annotated", "BinaryIO", "IO", "Match", "Pattern", "TextIO"]
@@ -199,12 +197,13 @@ ClassVar: _SpecialForm
Optional: _SpecialForm
Tuple: _SpecialForm
if sys.version_info >= (3, 8):
Final: _SpecialForm
def final(f: _T) -> _T: ...
Literal: _SpecialForm
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
Final: _SpecialForm
def final(f: _T) -> _T: ...
Literal: _SpecialForm
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
if sys.version_info >= (3, 11):
Self: _SpecialForm
@@ -329,8 +328,6 @@ if sys.version_info >= (3, 9):
# Predefined type variables.
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001
# Technically in 3.7 this inherited from GenericMeta. But let's not reflect that, since
# type checkers tend to assume that Protocols all have the ABCMeta metaclass.
class _ProtocolMeta(ABCMeta):
if sys.version_info >= (3, 12):
def __init__(cls, *args: Any, **kwargs: Any) -> None: ...
@@ -358,11 +355,10 @@ class SupportsBytes(Protocol, metaclass=ABCMeta):
@abstractmethod
def __bytes__(self) -> bytes: ...
if sys.version_info >= (3, 8):
@runtime_checkable
class SupportsIndex(Protocol, metaclass=ABCMeta):
@abstractmethod
def __index__(self) -> int: ...
@runtime_checkable
class SupportsIndex(Protocol, metaclass=ABCMeta):
@abstractmethod
def __index__(self) -> int: ...
@runtime_checkable
class SupportsAbs(Protocol[_T_co]):
@@ -602,9 +598,7 @@ class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co,
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, item: object) -> bool: ...
def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
def __or__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __ror__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __sub__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
@@ -618,9 +612,7 @@ class KeysView(MappingView, AbstractSet[_KT_co]):
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, key: object) -> bool: ...
def __iter__(self) -> Iterator[_KT_co]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT_co]: ...
def __reversed__(self) -> Iterator[_KT_co]: ...
def __or__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
def __ror__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
def __sub__(self, other: Iterable[Any]) -> set[_KT_co]: ...
@@ -632,8 +624,7 @@ class ValuesView(MappingView, Collection[_VT_co]):
def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented
def __contains__(self, value: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_VT_co]: ...
def __reversed__(self) -> Iterator[_VT_co]: ...
class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
# TODO: We wish the key type could also be covariant, but that doesn't work,
@@ -823,21 +814,22 @@ else:
obj: _get_type_hints_obj_allowed_types, globalns: dict[str, Any] | None = None, localns: dict[str, Any] | None = None
) -> dict[str, Any]: ...
if sys.version_info >= (3, 8):
def get_args(tp: Any) -> tuple[Any, ...]: ...
def get_args(tp: Any) -> tuple[Any, ...]: ...
if sys.version_info >= (3, 10):
@overload
def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ...
@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: ...
if sys.version_info >= (3, 10):
@overload
def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ...
@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 cast(typ: type[_T], val: Any) -> _T: ...
@@ -865,9 +857,7 @@ if sys.version_info >= (3, 11):
# Type constructors
class NamedTuple(tuple[Any, ...]):
if sys.version_info < (3, 8):
_field_types: ClassVar[collections.OrderedDict[str, type]]
elif sys.version_info < (3, 9):
if sys.version_info < (3, 9):
_field_types: ClassVar[dict[str, type]]
_field_defaults: ClassVar[dict[str, Any]]
_fields: ClassVar[tuple[str, ...]]
@@ -881,11 +871,7 @@ class NamedTuple(tuple[Any, ...]):
def __init__(self, __typename: str, __fields: None = None, **kwargs: Any) -> None: ...
@classmethod
def _make(cls, iterable: Iterable[Any]) -> typing_extensions.Self: ...
if sys.version_info >= (3, 8):
def _asdict(self) -> dict[str, Any]: ...
else:
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
def _asdict(self) -> dict[str, Any]: ...
def _replace(self, **kwargs: Any) -> typing_extensions.Self: ...
# Internal mypy fallback type for all typed dicts (does not exist at runtime)