Skip to content

Commit 6dcbc4c

Browse files
authored
[collections] Accept integer-like arguments and optional bounds in UserString (#16519)
1 parent 37e9746 commit 6dcbc4c

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

‎stdlib/collections/__init__.pyi‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,23 @@ class UserString(Sequence[UserString]):
191191
def __reversed__(self) -> Iterator[Self]: ...
192192
def __add__(self, other: object) -> Self: ...
193193
def __radd__(self, other: object) -> Self: ...
194-
def __mul__(self, n: int) -> Self: ...
195-
def __rmul__(self, n: int) -> Self: ...
194+
def __mul__(self, n: SupportsIndex) -> Self: ...
195+
def __rmul__(self, n: SupportsIndex) -> Self: ...
196196
def __mod__(self, args: Any) -> Self: ...
197197
def __rmod__(self, template: object) -> Self: ...
198198
def capitalize(self) -> Self: ...
199199
def casefold(self) -> Self: ...
200-
def center(self, width: int, *args: Any) -> Self: ...
201-
def count(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ...
200+
def center(self, width: SupportsIndex, *args: Any) -> Self: ...
201+
def count(self, sub: str | UserString, start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize) -> int: ...
202202
def encode(self: UserString, encoding: str | None = "utf-8", errors: str | None = "strict") -> bytes: ...
203-
def endswith(self, suffix: str | tuple[str, ...], start: int | None = 0, end: int | None = sys.maxsize) -> bool: ...
204-
def expandtabs(self, tabsize: int = 8) -> Self: ...
205-
def find(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ...
203+
def endswith(
204+
self, suffix: str | tuple[str, ...], start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize
205+
) -> bool: ...
206+
def expandtabs(self, tabsize: SupportsIndex = 8) -> Self: ...
207+
def find(self, sub: str | UserString, start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize) -> int: ...
206208
def format(self, *args: Any, **kwds: Any) -> str: ...
207209
def format_map(self, mapping: Mapping[str, Any]) -> str: ...
208-
def index(self, sub: str, start: int = 0, end: int = sys.maxsize) -> int: ...
210+
def index(self, sub: str, start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize) -> int: ...
209211
def isalpha(self) -> bool: ...
210212
def isalnum(self) -> bool: ...
211213
def isdecimal(self) -> bool: ...
@@ -219,29 +221,31 @@ class UserString(Sequence[UserString]):
219221
def isupper(self) -> bool: ...
220222
def isascii(self) -> bool: ...
221223
def join(self, seq: Iterable[str]) -> str: ...
222-
def ljust(self, width: int, *args: Any) -> Self: ...
224+
def ljust(self, width: SupportsIndex, *args: Any) -> Self: ...
223225
def lower(self) -> Self: ...
224226
def lstrip(self, chars: str | None = None) -> Self: ...
225227
maketrans = str.maketrans
226228
def partition(self, sep: str) -> tuple[str, str, str]: ...
227229
def removeprefix(self, prefix: str | UserString, /) -> Self: ...
228230
def removesuffix(self, suffix: str | UserString, /) -> Self: ...
229-
def replace(self, old: str | UserString, new: str | UserString, maxsplit: int = -1) -> Self: ...
230-
def rfind(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ...
231-
def rindex(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ...
232-
def rjust(self, width: int, *args: Any) -> Self: ...
231+
def replace(self, old: str | UserString, new: str | UserString, maxsplit: SupportsIndex = -1) -> Self: ...
232+
def rfind(self, sub: str | UserString, start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize) -> int: ...
233+
def rindex(self, sub: str | UserString, start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize) -> int: ...
234+
def rjust(self, width: SupportsIndex, *args: Any) -> Self: ...
233235
def rpartition(self, sep: str) -> tuple[str, str, str]: ...
234236
def rstrip(self, chars: str | None = None) -> Self: ...
235-
def split(self, sep: str | None = None, maxsplit: int = -1) -> list[str]: ...
236-
def rsplit(self, sep: str | None = None, maxsplit: int = -1) -> list[str]: ...
237+
def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ...
238+
def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ...
237239
def splitlines(self, keepends: bool = False) -> list[str]: ...
238-
def startswith(self, prefix: str | tuple[str, ...], start: int | None = 0, end: int | None = sys.maxsize) -> bool: ...
240+
def startswith(
241+
self, prefix: str | tuple[str, ...], start: SupportsIndex | None = 0, end: SupportsIndex | None = sys.maxsize
242+
) -> bool: ...
239243
def strip(self, chars: str | None = None) -> Self: ...
240244
def swapcase(self) -> Self: ...
241245
def title(self) -> Self: ...
242246
def translate(self, *args: Any) -> Self: ...
243247
def upper(self) -> Self: ...
244-
def zfill(self, width: int) -> Self: ...
248+
def zfill(self, width: SupportsIndex) -> Self: ...
245249

246250
@disjoint_base
247251
class deque(MutableSequence[_T]):

0 commit comments

Comments
 (0)