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

@@ -116,10 +116,7 @@ class object:
# return type of pickle methods is rather hard to express in the current type system
# see #6661 and https://docs.python.org/3/library/pickle.html#object.__reduce__
def __reduce__(self) -> str | tuple[Any, ...]: ...
if sys.version_info >= (3, 8):
def __reduce_ex__(self, __protocol: SupportsIndex) -> str | tuple[Any, ...]: ...
else:
def __reduce_ex__(self, __protocol: int) -> str | tuple[Any, ...]: ...
def __reduce_ex__(self, __protocol: SupportsIndex) -> str | tuple[Any, ...]: ...
if sys.version_info >= (3, 11):
def __getstate__(self) -> object: ...
@@ -227,9 +224,7 @@ class int:
def __new__(cls, __x: ConvertibleToInt = ...) -> Self: ...
@overload
def __new__(cls, __x: str | bytes | bytearray, base: SupportsIndex) -> Self: ...
if sys.version_info >= (3, 8):
def as_integer_ratio(self) -> tuple[int, Literal[1]]: ...
def as_integer_ratio(self) -> tuple[int, Literal[1]]: ...
@property
def real(self) -> int: ...
@property
@@ -393,22 +388,15 @@ class float:
def __bool__(self) -> bool: ...
class complex:
if sys.version_info >= (3, 8):
# Python doesn't currently accept SupportsComplex for the second argument
@overload
def __new__(
cls,
real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ...,
imag: complex | SupportsFloat | SupportsIndex = ...,
) -> Self: ...
@overload
def __new__(cls, real: str | SupportsComplex | SupportsFloat | SupportsIndex | complex) -> Self: ...
else:
@overload
def __new__(cls, real: complex | SupportsComplex | SupportsFloat = ..., imag: complex | SupportsFloat = ...) -> Self: ...
@overload
def __new__(cls, real: str | SupportsComplex | SupportsFloat | complex) -> Self: ...
# Python doesn't currently accept SupportsComplex for the second argument
@overload
def __new__(
cls,
real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ...,
imag: complex | SupportsFloat | SupportsIndex = ...,
) -> Self: ...
@overload
def __new__(cls, real: str | SupportsComplex | SupportsFloat | SupportsIndex | complex) -> Self: ...
@property
def real(self) -> float: ...
@property
@@ -462,17 +450,10 @@ class str(Sequence[str]):
def endswith(
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> bool: ...
if sys.version_info >= (3, 8):
@overload
def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
@overload
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
else:
@overload
def expandtabs(self: LiteralString, tabsize: int = 8) -> LiteralString: ...
@overload
def expandtabs(self, tabsize: int = 8) -> str: ... # type: ignore[misc]
@overload
def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
@overload
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
@overload
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
@@ -639,19 +620,11 @@ class bytes(Sequence[int]):
__start: SupportsIndex | None = ...,
__end: SupportsIndex | None = ...,
) -> bool: ...
if sys.version_info >= (3, 8):
def expandtabs(self, tabsize: SupportsIndex = 8) -> bytes: ...
else:
def expandtabs(self, tabsize: int = ...) -> bytes: ...
def expandtabs(self, tabsize: SupportsIndex = 8) -> bytes: ...
def find(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
if sys.version_info >= (3, 8):
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
else:
def hex(self) -> str: ...
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
def index(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
@@ -747,20 +720,12 @@ class bytearray(MutableSequence[int]):
__start: SupportsIndex | None = ...,
__end: SupportsIndex | None = ...,
) -> bool: ...
if sys.version_info >= (3, 8):
def expandtabs(self, tabsize: SupportsIndex = 8) -> bytearray: ...
else:
def expandtabs(self, tabsize: int = ...) -> bytearray: ...
def expandtabs(self, tabsize: SupportsIndex = 8) -> bytearray: ...
def extend(self, __iterable_of_ints: Iterable[SupportsIndex]) -> None: ...
def find(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
if sys.version_info >= (3, 8):
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
else:
def hex(self) -> str: ...
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
def index(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
@@ -891,21 +856,13 @@ class memoryview(Sequence[int]):
def __setitem__(self, __key: SupportsIndex, __value: SupportsIndex) -> None: ...
if sys.version_info >= (3, 10):
def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ...
elif sys.version_info >= (3, 8):
def tobytes(self, order: Literal["C", "F", "A"] | None = None) -> bytes: ...
else:
def tobytes(self) -> bytes: ...
def tobytes(self, order: Literal["C", "F", "A"] | None = None) -> bytes: ...
def tolist(self) -> list[int]: ...
if sys.version_info >= (3, 8):
def toreadonly(self) -> memoryview: ...
def toreadonly(self) -> memoryview: ...
def release(self) -> None: ...
if sys.version_info >= (3, 8):
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
else:
def hex(self) -> str: ...
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ...
def __buffer__(self, __flags: int) -> memoryview: ...
def __release_buffer__(self, __buffer: memoryview) -> None: ...
@@ -1119,8 +1076,7 @@ class dict(MutableMapping[_KT, _VT]):
def __delitem__(self, __key: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
def __eq__(self, __value: object) -> bool: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT]: ...
def __reversed__(self) -> Iterator[_KT]: ...
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
@@ -1297,89 +1253,49 @@ if sys.version_info >= (3, 10):
# compile() returns a CodeType, unless the flags argument includes PyCF_ONLY_AST (=1024),
# in which case it returns ast.AST. We have overloads for flag 0 (the default) and for
# explicitly passing PyCF_ONLY_AST. We fall back to Any for other values of flags.
if sys.version_info >= (3, 8):
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: Literal[0],
dont_inherit: bool = False,
optimize: int = -1,
*,
_feature_version: int = -1,
) -> CodeType: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
*,
dont_inherit: bool = False,
optimize: int = -1,
_feature_version: int = -1,
) -> CodeType: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: Literal[1024],
dont_inherit: bool = False,
optimize: int = -1,
*,
_feature_version: int = -1,
) -> _ast.AST: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: int,
dont_inherit: bool = False,
optimize: int = -1,
*,
_feature_version: int = -1,
) -> Any: ...
else:
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: Literal[0],
dont_inherit: bool = False,
optimize: int = -1,
) -> CodeType: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
*,
dont_inherit: bool = False,
optimize: int = -1,
) -> CodeType: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: Literal[1024],
dont_inherit: bool = False,
optimize: int = -1,
) -> _ast.AST: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: int,
dont_inherit: bool = False,
optimize: int = -1,
) -> Any: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: Literal[0],
dont_inherit: bool = False,
optimize: int = -1,
*,
_feature_version: int = -1,
) -> CodeType: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
*,
dont_inherit: bool = False,
optimize: int = -1,
_feature_version: int = -1,
) -> CodeType: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: Literal[1024],
dont_inherit: bool = False,
optimize: int = -1,
*,
_feature_version: int = -1,
) -> _ast.AST: ...
@overload
def compile(
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
filename: str | ReadableBuffer | _PathLike[Any],
mode: str,
flags: int,
dont_inherit: bool = False,
optimize: int = -1,
*,
_feature_version: int = -1,
) -> Any: ...
def copyright() -> None: ...
def credits() -> None: ...
def delattr(__obj: object, __name: str) -> None: ...
@@ -1673,77 +1589,45 @@ _SupportsSomeKindOfPow = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs a
_SupportsPow2[Any, Any] | _SupportsPow3NoneOnly[Any, Any] | _SupportsPow3[Any, Any, Any]
)
if sys.version_info >= (3, 8):
# TODO: `pow(int, int, Literal[0])` fails at runtime,
# but adding a `NoReturn` overload isn't a good solution for expressing that (see #8566).
@overload
def pow(base: int, exp: int, mod: int) -> int: ...
@overload
def pow(base: int, exp: Literal[0], mod: None = None) -> Literal[1]: ...
@overload
def pow(base: int, exp: _PositiveInteger, mod: None = None) -> int: ...
@overload
def pow(base: int, exp: _NegativeInteger, mod: None = None) -> float: ...
# int base & positive-int exp -> int; int base & negative-int exp -> float
# return type must be Any as `int | float` causes too many false-positive errors
@overload
def pow(base: int, exp: int, mod: None = None) -> Any: ...
@overload
def pow(base: _PositiveInteger, exp: float, mod: None = None) -> float: ...
@overload
def pow(base: _NegativeInteger, exp: float, mod: None = None) -> complex: ...
@overload
def pow(base: float, exp: int, mod: None = None) -> float: ...
# float base & float exp could return float or complex
# return type must be Any (same as complex base, complex exp),
# as `float | complex` causes too many false-positive errors
@overload
def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> Any: ...
@overload
def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> complex: ...
@overload
def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ...
@overload
def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ...
@overload
def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ...
@overload
def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any: ...
@overload
def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex: ...
# TODO: `pow(int, int, Literal[0])` fails at runtime,
# but adding a `NoReturn` overload isn't a good solution for expressing that (see #8566).
@overload
def pow(base: int, exp: int, mod: int) -> int: ...
@overload
def pow(base: int, exp: Literal[0], mod: None = None) -> Literal[1]: ...
@overload
def pow(base: int, exp: _PositiveInteger, mod: None = None) -> int: ...
@overload
def pow(base: int, exp: _NegativeInteger, mod: None = None) -> float: ...
else:
@overload
def pow(__x: int, __y: int, __z: int) -> int: ...
@overload
def pow(__x: int, __y: Literal[0], __z: None = None) -> Literal[1]: ...
@overload
def pow(__x: int, __y: _PositiveInteger, __z: None = None) -> int: ...
@overload
def pow(__x: int, __y: _NegativeInteger, __z: None = None) -> float: ...
@overload
def pow(__x: int, __y: int, __z: None = None) -> Any: ...
@overload
def pow(__x: _PositiveInteger, __y: float, __z: None = None) -> float: ...
@overload
def pow(__x: _NegativeInteger, __y: float, __z: None = None) -> complex: ...
@overload
def pow(__x: float, __y: int, __z: None = None) -> float: ...
@overload
def pow(__x: float, __y: complex | _SupportsSomeKindOfPow, __z: None = None) -> Any: ...
@overload
def pow(__x: complex, __y: complex | _SupportsSomeKindOfPow, __z: None = None) -> complex: ...
@overload
def pow(__x: _SupportsPow2[_E, _T_co], __y: _E, __z: None = None) -> _T_co: ...
@overload
def pow(__x: _SupportsPow3NoneOnly[_E, _T_co], __y: _E, __z: None = None) -> _T_co: ...
@overload
def pow(__x: _SupportsPow3[_E, _M, _T_co], __y: _E, __z: _M) -> _T_co: ...
@overload
def pow(__x: _SupportsSomeKindOfPow, __y: float, __z: None = None) -> Any: ...
@overload
def pow(__x: _SupportsSomeKindOfPow, __y: complex, __z: None = None) -> complex: ...
# int base & positive-int exp -> int; int base & negative-int exp -> float
# return type must be Any as `int | float` causes too many false-positive errors
@overload
def pow(base: int, exp: int, mod: None = None) -> Any: ...
@overload
def pow(base: _PositiveInteger, exp: float, mod: None = None) -> float: ...
@overload
def pow(base: _NegativeInteger, exp: float, mod: None = None) -> complex: ...
@overload
def pow(base: float, exp: int, mod: None = None) -> float: ...
# float base & float exp could return float or complex
# return type must be Any (same as complex base, complex exp),
# as `float | complex` causes too many false-positive errors
@overload
def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> Any: ...
@overload
def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> complex: ...
@overload
def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ...
@overload
def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ...
@overload
def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ...
@overload
def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any: ...
@overload
def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex: ...
def quit(code: sys._ExitCode = None) -> NoReturn: ...
class reversed(Iterator[_T]):
@@ -1793,24 +1677,12 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
# However, we can't express that in the stub for `sum()`
# without creating many false-positive errors (see #7578).
# Instead, we special-case the most common examples of this: bool and literal integers.
if sys.version_info >= (3, 8):
@overload
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[overload-overlap]
else:
@overload
def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = 0) -> int: ... # type: ignore[overload-overlap]
@overload
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[overload-overlap]
@overload
def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ...
if sys.version_info >= (3, 8):
@overload
def sum(__iterable: Iterable[_AddableT1], start: _AddableT2) -> _AddableT1 | _AddableT2: ...
else:
@overload
def sum(__iterable: Iterable[_AddableT1], __start: _AddableT2) -> _AddableT1 | _AddableT2: ...
@overload
def sum(__iterable: Iterable[_AddableT1], start: _AddableT2) -> _AddableT1 | _AddableT2: ...
# The argument to `vars()` has to have a `__dict__` attribute, so the second overload can't be annotated with `object`
# (A "SupportsDunderDict" protocol doesn't work)