Use SupportsIndex where applicable in builtins.pyi (#5739)

* Use `SupportsIndex` where applicable in `builtins.pyi`

* Remove `None` from the `int.__round__` ndigits parameter
This commit is contained in:
Bas van Beek
2021-07-09 12:08:19 +02:00
committed by GitHub
parent 0330530de0
commit 5e23e2c19a
2 changed files with 22 additions and 18 deletions

View File

@@ -106,7 +106,10 @@ class object:
def __delattr__(self, name: str) -> None: ...
def __sizeof__(self) -> int: ...
def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ...
def __reduce_ex__(self, protocol: int) -> Union[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 __dir__(self) -> Iterable[str]: ...
def __init_subclass__(cls) -> None: ...
@@ -171,7 +174,7 @@ class int:
@overload
def __new__(cls: Type[_T], x: Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc] = ...) -> _T: ...
@overload
def __new__(cls: Type[_T], x: Union[str, bytes, bytearray], base: int) -> _T: ...
def __new__(cls: Type[_T], x: Union[str, bytes, bytearray], base: SupportsIndex) -> _T: ...
if sys.version_info >= (3, 8):
def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ...
@property
@@ -186,10 +189,10 @@ class int:
def bit_length(self) -> int: ...
if sys.version_info >= (3, 10):
def bit_count(self) -> int: ...
def to_bytes(self, length: int, byteorder: Literal["little", "big"], *, signed: bool = ...) -> bytes: ...
def to_bytes(self, length: SupportsIndex, byteorder: Literal["little", "big"], *, signed: bool = ...) -> bytes: ...
@classmethod
def from_bytes(
cls, bytes: Union[Iterable[int], SupportsBytes], byteorder: Literal["little", "big"], *, signed: bool = ...
cls, bytes: Iterable[SupportsIndex] | SupportsBytes, byteorder: Literal["little", "big"], *, signed: bool = ...
) -> int: ... # TODO buffer object argument
def __add__(self, x: int) -> int: ...
def __sub__(self, x: int) -> int: ...
@@ -226,7 +229,7 @@ class int:
def __trunc__(self) -> int: ...
def __ceil__(self) -> int: ...
def __floor__(self) -> int: ...
def __round__(self, ndigits: Optional[int] = ...) -> int: ...
def __round__(self, ndigits: SupportsIndex = ...) -> int: ...
def __getnewargs__(self) -> Tuple[int]: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
@@ -280,7 +283,7 @@ class float:
@overload
def __round__(self, ndigits: None = ...) -> int: ...
@overload
def __round__(self, ndigits: int) -> float: ...
def __round__(self, ndigits: SupportsIndex) -> float: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: float) -> bool: ...
@@ -716,7 +719,7 @@ class slice(object):
@overload
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
def indices(self, len: int) -> Tuple[int, int, int]: ...
def indices(self, len: SupportsIndex) -> Tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
def __new__(cls: Type[_T], iterable: Iterable[_T_co] = ...) -> _T: ...
@@ -735,10 +738,10 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ...
@overload
def __add__(self, x: Tuple[_T, ...]) -> Tuple[Union[_T_co, _T], ...]: ...
def __mul__(self, n: int) -> Tuple[_T_co, ...]: ...
def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ...
def __mul__(self, n: SupportsIndex) -> Tuple[_T_co, ...]: ...
def __rmul__(self, n: SupportsIndex) -> Tuple[_T_co, ...]: ...
def count(self, __value: Any) -> int: ...
def index(self, __value: Any, __start: int = ..., __stop: int = ...) -> int: ...
def index(self, __value: Any, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
@@ -759,10 +762,10 @@ class list(MutableSequence[_T], Generic[_T]):
def copy(self) -> List[_T]: ...
def append(self, __object: _T) -> None: ...
def extend(self, __iterable: Iterable[_T]) -> None: ...
def pop(self, __index: int = ...) -> _T: ...
def index(self, __value: _T, __start: int = ..., __stop: int = ...) -> int: ...
def pop(self, __index: SupportsIndex = ...) -> _T: ...
def index(self, __value: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
def count(self, __value: _T) -> int: ...
def insert(self, __index: int, __object: _T) -> None: ...
def insert(self, __index: SupportsIndex, __object: _T) -> None: ...
def remove(self, __value: _T) -> None: ...
def reverse(self) -> None: ...
@overload
@@ -784,9 +787,9 @@ class list(MutableSequence[_T], Generic[_T]):
def __delitem__(self, i: Union[SupportsIndex, slice]) -> None: ...
def __add__(self, x: List[_T]) -> List[_T]: ...
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
def __mul__(self, n: int) -> List[_T]: ...
def __rmul__(self, n: int) -> List[_T]: ...
def __imul__(self: _S, n: int) -> _S: ...
def __mul__(self, n: SupportsIndex) -> List[_T]: ...
def __rmul__(self, n: SupportsIndex) -> List[_T]: ...
def __imul__(self: _S, n: SupportsIndex) -> _S: ...
def __contains__(self, o: object) -> bool: ...
def __reversed__(self) -> Iterator[_T]: ...
def __gt__(self, x: List[_T]) -> bool: ...
@@ -1296,7 +1299,7 @@ def round(number: SupportsRound[Any]) -> int: ...
@overload
def round(number: SupportsRound[Any], ndigits: None) -> int: ...
@overload
def round(number: SupportsRound[_T], ndigits: int) -> _T: ...
def round(number: SupportsRound[_T], ndigits: SupportsIndex) -> _T: ...
def setattr(__obj: Any, __name: str, __value: Any) -> None: ...
@overload
def sorted(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., reverse: bool = ...) -> List[SupportsLessThanT]: ...