From b80a348de8ee016aa85b8107b76c6545aa25a2e6 Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Sat, 26 Jun 2021 15:21:05 +0200 Subject: [PATCH 1/3] Use `SupportsIndex` where applicable in 4 classes * `str` * `bytes` * `bytearray` * `memoryview` --- stdlib/builtins.pyi | 120 ++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index de7194ed75c2..96be6014ec57 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -334,13 +334,13 @@ class str(Sequence[str]): def __new__(cls: Type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... def capitalize(self) -> str: ... def casefold(self) -> str: ... - def center(self, __width: int, __fillchar: str = ...) -> str: ... + def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... 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[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> str: ... + def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... 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: ... @@ -359,21 +359,21 @@ class str(Sequence[str]): def istitle(self) -> bool: ... def isupper(self) -> bool: ... def join(self, __iterable: Iterable[str]) -> str: ... - def ljust(self, __width: int, __fillchar: str = ...) -> str: ... + def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... def lower(self) -> str: ... def lstrip(self, __chars: Optional[str] = ...) -> str: ... def partition(self, __sep: str) -> Tuple[str, str, str]: ... - def replace(self, __old: str, __new: str, __count: int = ...) -> str: ... + def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> 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[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 rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def rsplit(self, sep: Optional[str] = ..., maxsplit: SupportsIndex = ...) -> List[str]: ... def rstrip(self, __chars: Optional[str] = ...) -> str: ... - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def split(self, sep: Optional[str] = ..., maxsplit: SupportsIndex = ...) -> List[str]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( self, __prefix: Union[str, Tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... @@ -383,7 +383,7 @@ class str(Sequence[str]): def title(self) -> str: ... def translate(self, __table: Union[Mapping[int, Union[int, str, None]], Sequence[Union[int, str, None]]]) -> str: ... def upper(self) -> str: ... - def zfill(self, __width: int) -> str: ... + def zfill(self, __width: SupportsIndex) -> str: ... @staticmethod @overload def maketrans(__x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... @@ -403,28 +403,28 @@ class str(Sequence[str]): def __len__(self) -> int: ... def __lt__(self, x: str) -> bool: ... def __mod__(self, x: Any) -> str: ... - def __mul__(self, n: int) -> str: ... + def __mul__(self, n: SupportsIndex) -> str: ... def __ne__(self, x: object) -> bool: ... def __repr__(self) -> str: ... - def __rmul__(self, n: int) -> str: ... + def __rmul__(self, n: SupportsIndex) -> str: ... def __str__(self) -> str: ... def __getnewargs__(self) -> Tuple[str]: ... class bytes(ByteString): @overload - def __new__(cls: Type[_T], ints: Iterable[int]) -> _T: ... + def __new__(cls: Type[_T], ints: Iterable[SupportsIndex]) -> _T: ... @overload def __new__(cls: Type[_T], string: str, encoding: str, errors: str = ...) -> _T: ... @overload - def __new__(cls: Type[_T], length: int) -> _T: ... + def __new__(cls: Type[_T], length: SupportsIndex) -> _T: ... @overload def __new__(cls: Type[_T]) -> _T: ... @overload def __new__(cls: Type[_T], o: SupportsBytes) -> _T: ... def capitalize(self) -> bytes: ... - def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... + def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def count( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( @@ -433,16 +433,16 @@ class bytes(ByteString): __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> bytes: ... + def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... def find( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ... + def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... else: def hex(self) -> str: ... def index( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -454,25 +454,25 @@ class bytes(ByteString): def istitle(self) -> bool: ... def isupper(self) -> bool: ... def join(self, __iterable_of_bytes: Iterable[Union[ByteString, memoryview]]) -> bytes: ... - def ljust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... + def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def lower(self) -> bytes: ... def lstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... def partition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... - def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytes: ... + def replace(self, __old: bytes, __new: bytes, __count: SupportsIndex = ...) -> bytes: ... 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[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rindex( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... - def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... + def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ... + def rsplit(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... def rstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ... + def split(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith( self, @@ -485,7 +485,7 @@ class bytes(ByteString): def title(self) -> bytes: ... def translate(self, __table: Optional[bytes], delete: bytes = ...) -> bytes: ... def upper(self) -> bytes: ... - def zfill(self, __width: int) -> bytes: ... + def zfill(self, __width: SupportsIndex) -> bytes: ... @classmethod def fromhex(cls, __s: str) -> bytes: ... @staticmethod @@ -496,15 +496,15 @@ class bytes(ByteString): def __repr__(self) -> str: ... def __hash__(self) -> int: ... @overload - def __getitem__(self, i: int) -> int: ... + def __getitem__(self, i: SupportsIndex) -> int: ... @overload def __getitem__(self, s: slice) -> bytes: ... def __add__(self, s: bytes) -> bytes: ... - def __mul__(self, n: int) -> bytes: ... - def __rmul__(self, n: int) -> bytes: ... + def __mul__(self, n: SupportsIndex) -> bytes: ... + def __rmul__(self, n: SupportsIndex) -> bytes: ... def __mod__(self, value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore + def __contains__(self, o: SupportsIndex | bytes) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: bytes) -> bool: ... @@ -517,16 +517,16 @@ class bytearray(MutableSequence[int], ByteString): @overload def __init__(self) -> None: ... @overload - def __init__(self, ints: Iterable[int]) -> None: ... + def __init__(self, ints: Iterable[SupportsIndex]) -> None: ... @overload def __init__(self, string: str, encoding: str, errors: str = ...) -> None: ... @overload - def __init__(self, length: int) -> None: ... - def append(self, __item: int) -> None: ... + def __init__(self, length: SupportsIndex) -> None: ... + def append(self, __item: SupportsIndex) -> None: ... def capitalize(self) -> bytearray: ... - def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... def count( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def copy(self) -> bytearray: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... @@ -536,19 +536,19 @@ class bytearray(MutableSequence[int], ByteString): __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def extend(self, __iterable_of_ints: Iterable[int]) -> None: ... + def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... + def extend(self, __iterable_of_ints: Iterable[SupportsIndex]) -> None: ... def find( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ... + def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... else: def hex(self) -> str: ... def index( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... - def insert(self, __index: int, __item: int) -> None: ... + def insert(self, __index: SupportsIndex, __item: SupportsIndex) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... if sys.version_info >= (3, 7): @@ -559,25 +559,25 @@ class bytearray(MutableSequence[int], ByteString): def istitle(self) -> bool: ... def isupper(self) -> bool: ... def join(self, __iterable_of_bytes: Iterable[Union[ByteString, memoryview]]) -> bytearray: ... - def ljust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: bytes) -> bytearray: ... def removesuffix(self, __suffix: bytes) -> bytearray: ... - def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... + def replace(self, __old: bytes, __new: bytes, __count: SupportsIndex = ...) -> bytearray: ... def rfind( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rindex( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... - def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rsplit(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def split(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, @@ -590,7 +590,7 @@ class bytearray(MutableSequence[int], ByteString): def title(self) -> bytearray: ... def translate(self, __table: Optional[bytes], delete: bytes = ...) -> bytearray: ... def upper(self) -> bytearray: ... - def zfill(self, __width: int) -> bytearray: ... + def zfill(self, __width: SupportsIndex) -> bytearray: ... @classmethod def fromhex(cls, __string: str) -> bytearray: ... @staticmethod @@ -601,22 +601,22 @@ class bytearray(MutableSequence[int], ByteString): def __repr__(self) -> str: ... __hash__: None # type: ignore @overload - def __getitem__(self, i: int) -> int: ... + def __getitem__(self, i: SupportsIndex) -> int: ... @overload def __getitem__(self, s: slice) -> bytearray: ... @overload - def __setitem__(self, i: int, x: int) -> None: ... + def __setitem__(self, i: SupportsIndex, x: SupportsIndex) -> None: ... @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __setitem__(self, s: slice, x: Iterable[SupportsIndex] | bytes) -> None: ... + def __delitem__(self, i: SupportsIndex | slice) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __iadd__(self, s: Iterable[int]) -> bytearray: ... - def __mul__(self, n: int) -> bytearray: ... - def __rmul__(self, n: int) -> bytearray: ... - def __imul__(self, n: int) -> bytearray: ... + def __mul__(self, n: SupportsIndex) -> bytearray: ... + def __rmul__(self, n: SupportsIndex) -> bytearray: ... + def __imul__(self, n: SupportsIndex) -> bytearray: ... def __mod__(self, value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore + def __contains__(self, o: SupportsIndex | bytes) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: bytes) -> bool: ... @@ -645,7 +645,7 @@ class memoryview(Sized, Sequence[int]): ) -> None: ... def cast(self, format: str, shape: Union[List[int], Tuple[int]] = ...) -> memoryview: ... @overload - def __getitem__(self, i: int) -> int: ... + def __getitem__(self, i: SupportsIndex) -> int: ... @overload def __getitem__(self, s: slice) -> memoryview: ... def __contains__(self, x: object) -> bool: ... @@ -654,7 +654,7 @@ class memoryview(Sized, Sequence[int]): @overload def __setitem__(self, s: slice, o: bytes) -> None: ... @overload - def __setitem__(self, i: int, o: int) -> None: ... + def __setitem__(self, i: SupportsIndex, o: SupportsIndex) -> None: ... if sys.version_info >= (3, 8): def tobytes(self, order: Optional[Literal["C", "F", "A"]] = ...) -> bytes: ... else: @@ -664,7 +664,7 @@ class memoryview(Sized, Sequence[int]): def toreadonly(self) -> memoryview: ... def release(self) -> None: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ... + def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... else: def hex(self) -> str: ... From 8df65cf93920ce32bc5b134faa56b869fc9b9d3a Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Sat, 26 Jun 2021 16:21:23 +0200 Subject: [PATCH 2/3] Do not allow `SupportsIndex` in `expandtabs` for python < 3.8 --- stdlib/builtins.pyi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 96be6014ec57..428139f422c5 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -340,7 +340,10 @@ class str(Sequence[str]): def endswith( self, __suffix: Union[str, Tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> bool: ... - def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... + if sys.version_info >= (3, 8): + def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... + else: + def expandtabs(self, tabsize: int = ...) -> str: ... 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: ... @@ -433,7 +436,10 @@ class bytes(ByteString): __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... - def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... + if sys.version_info >= (3, 8): + def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... + else: + def expandtabs(self, tabsize: int = ...) -> bytes: ... def find( self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... @@ -536,7 +542,10 @@ class bytearray(MutableSequence[int], ByteString): __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... - def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... + if sys.version_info >= (3, 8): + def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... + else: + def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, __iterable_of_ints: Iterable[SupportsIndex]) -> None: ... def find( self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... From 8ef430da380b6d1846b67fab1321af80a171062c Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Sat, 26 Jun 2021 16:34:33 +0200 Subject: [PATCH 3/3] Propagate the new `SupportsIndex`-related `str` changes to the `markupsafe` package --- stubs/MarkupSafe/markupsafe/__init__.pyi | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/stubs/MarkupSafe/markupsafe/__init__.pyi b/stubs/MarkupSafe/markupsafe/__init__.pyi index 1824c4d8e368..272e4f75e4fa 100644 --- a/stubs/MarkupSafe/markupsafe/__init__.pyi +++ b/stubs/MarkupSafe/markupsafe/__init__.pyi @@ -1,6 +1,7 @@ import string import sys from typing import Any, Callable, Iterable, Mapping, Optional, Sequence, Text, Tuple, Union +from typing_extensions import SupportsIndex from markupsafe._compat import text_type from markupsafe._native import escape as escape, escape_silent as escape_silent, soft_unicode as soft_unicode @@ -10,12 +11,12 @@ class Markup(text_type): def __html__(self) -> Markup: ... def __add__(self, other: text_type) -> Markup: ... def __radd__(self, other: text_type) -> Markup: ... - def __mul__(self, num: int) -> Markup: ... - def __rmul__(self, num: int) -> Markup: ... + def __mul__(self, num: int) -> Markup: ... # type: ignore + def __rmul__(self, num: int) -> Markup: ... # type: ignore def __mod__(self, *args: Any) -> Markup: ... def join(self, seq: Iterable[text_type]) -> Markup: ... - def split(self, sep: Optional[text_type] = ..., maxsplit: int = ...) -> list[Markup]: ... # type: ignore - def rsplit(self, sep: Optional[text_type] = ..., maxsplit: int = ...) -> list[Markup]: ... # type: ignore + def split(self, sep: Optional[text_type] = ..., maxsplit: SupportsIndex = ...) -> list[Markup]: ... # type: ignore + def rsplit(self, sep: Optional[text_type] = ..., maxsplit: SupportsIndex = ...) -> list[Markup]: ... # type: ignore def splitlines(self, keepends: bool = ...) -> list[Markup]: ... # type: ignore def unescape(self) -> Text: ... def striptags(self) -> Text: ... @@ -32,18 +33,21 @@ class Markup(text_type): def lower(self) -> Markup: ... def upper(self) -> Markup: ... def swapcase(self) -> Markup: ... - def replace(self, old: text_type, new: text_type, count: int = ...) -> Markup: ... - def ljust(self, width: int, fillchar: text_type = ...) -> Markup: ... - def rjust(self, width: int, fillchar: text_type = ...) -> Markup: ... + def replace(self, old: text_type, new: text_type, count: SupportsIndex = ...) -> Markup: ... + def ljust(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... + def rjust(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... def lstrip(self, chars: Optional[text_type] = ...) -> Markup: ... def rstrip(self, chars: Optional[text_type] = ...) -> Markup: ... def strip(self, chars: Optional[text_type] = ...) -> Markup: ... - def center(self, width: int, fillchar: text_type = ...) -> Markup: ... - def zfill(self, width: int) -> Markup: ... + def center(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... + def zfill(self, width: SupportsIndex) -> Markup: ... def translate( self, table: Union[Mapping[int, Union[int, text_type, None]], Sequence[Union[int, text_type, None]]] ) -> Markup: ... - def expandtabs(self, tabsize: int = ...) -> Markup: ... + if sys.version_info >= (3, 8): + def expandtabs(self, tabsize: SupportsIndex = ...) -> Markup: ... + else: + def expandtabs(self, tabsize: int = ...) -> Markup: ... class EscapeFormatter(string.Formatter): escape: Callable[[text_type], Markup]