Skip to content

Fixes #1110. Use SupportsIndex in str, bytes and bytesarray functions wh… #5228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 59 additions & 21 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,19 @@ class str(Sequence[str]):
def capitalize(self) -> str: ...
def casefold(self) -> str: ...
def center(self, __width: int, __fillchar: str = ...) -> str: ...
def count(self, x: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def count(self, x: str, __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...) -> int: ...
def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
def endswith(
self, __suffix: Union[str, Tuple[str, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
self,
__suffix: Union[str, Tuple[str, ...]],
__start: Optional[_SupportsIndex] = ...,
__end: Optional[_SupportsIndex] = ...,
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> str: ...
def find(self, __sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def find(self, __sub: str, __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...) -> int: ...
def format(self, *args: object, **kwargs: object) -> str: ...
def format_map(self, map: _FormatMapMapping) -> str: ...
def index(self, __sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def index(self, __sub: str, __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
if sys.version_info >= (3, 7):
Expand All @@ -367,16 +370,19 @@ class str(Sequence[str]):
if sys.version_info >= (3, 9):
def removeprefix(self, __prefix: str) -> str: ...
def removesuffix(self, __suffix: str) -> str: ...
def rfind(self, __sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def rindex(self, __sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def rfind(self, __sub: str, __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...) -> int: ...
def rindex(self, __sub: str, __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...) -> int: ...
def rjust(self, __width: int, __fillchar: str = ...) -> str: ...
def rpartition(self, __sep: str) -> Tuple[str, str, str]: ...
def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
def rstrip(self, __chars: Optional[str] = ...) -> str: ...
def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
def splitlines(self, keepends: bool = ...) -> List[str]: ...
def startswith(
self, __prefix: Union[str, Tuple[str, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
self,
__prefix: Union[str, Tuple[str, ...]],
__start: Optional[_SupportsIndex] = ...,
__end: Optional[_SupportsIndex] = ...,
) -> bool: ...
def strip(self, __chars: Optional[str] = ...) -> str: ...
def swapcase(self) -> str: ...
Expand Down Expand Up @@ -423,18 +429,27 @@ class bytes(ByteString):
def __new__(cls: Type[_T], o: SupportsBytes) -> _T: ...
def capitalize(self) -> bytes: ...
def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ...
def count(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def count(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def decode(self, encoding: str = ..., errors: str = ...) -> str: ...
def endswith(
self, __suffix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
self,
__suffix: Union[bytes, Tuple[bytes, ...]],
__start: Optional[_SupportsIndex] = ...,
__end: Optional[_SupportsIndex] = ...,
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> bytes: ...
def find(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def find(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
if sys.version_info >= (3, 8):
def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ...
else:
def hex(self) -> str: ...
def index(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def index(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
if sys.version_info >= (3, 7):
Expand All @@ -453,16 +468,23 @@ class bytes(ByteString):
if sys.version_info >= (3, 9):
def removeprefix(self, __prefix: bytes) -> bytes: ...
def removesuffix(self, __suffix: bytes) -> bytes: ...
def rfind(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def rindex(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def rfind(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def rindex(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ...
def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ...
def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ...
def rstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ...
def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ...
def splitlines(self, keepends: bool = ...) -> List[bytes]: ...
def startswith(
self, __prefix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
self,
__prefix: Union[bytes, Tuple[bytes, ...]],
__start: Optional[_SupportsIndex] = ...,
__end: Optional[_SupportsIndex] = ...,
) -> bool: ...
def strip(self, __bytes: Optional[bytes] = ...) -> bytes: ...
def swapcase(self) -> bytes: ...
Expand Down Expand Up @@ -509,20 +531,29 @@ class bytearray(MutableSequence[int], ByteString):
def append(self, __item: int) -> None: ...
def capitalize(self) -> bytearray: ...
def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ...
def count(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def count(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def copy(self) -> bytearray: ...
def decode(self, encoding: str = ..., errors: str = ...) -> str: ...
def endswith(
self, __suffix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
self,
__suffix: Union[bytes, Tuple[bytes, ...]],
__start: Optional[_SupportsIndex] = ...,
__end: Optional[_SupportsIndex] = ...,
) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> bytearray: ...
def extend(self, __iterable_of_ints: Iterable[int]) -> None: ...
def find(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def find(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
if sys.version_info >= (3, 8):
def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ...
else:
def hex(self) -> str: ...
def index(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def index(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def insert(self, __index: int, __item: int) -> None: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
Expand All @@ -542,16 +573,23 @@ class bytearray(MutableSequence[int], ByteString):
def removeprefix(self, __prefix: bytes) -> bytearray: ...
def removesuffix(self, __suffix: bytes) -> bytearray: ...
def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ...
def rfind(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def rindex(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def rfind(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def rindex(
self, __sub: Union[bytes, int], __start: Optional[_SupportsIndex] = ..., __end: Optional[_SupportsIndex] = ...
) -> int: ...
def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ...
def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ...
def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ...
def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ...
def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ...
def splitlines(self, keepends: bool = ...) -> List[bytearray]: ...
def startswith(
self, __prefix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ...
self,
__prefix: Union[bytes, Tuple[bytes, ...]],
__start: Optional[_SupportsIndex] = ...,
__end: Optional[_SupportsIndex] = ...,
) -> bool: ...
def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ...
def swapcase(self) -> bytearray: ...
Expand Down