Use _typeshed.Self in Python 2, too (#6932)

This commit is contained in:
Alex Waygood
2022-01-16 22:44:51 +00:00
committed by GitHub
parent 0949e9e90d
commit 6a88d5e7ae
29 changed files with 156 additions and 160 deletions

View File

@@ -1,6 +1,6 @@
from _typeshed import Self
from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, overload
_UST = TypeVar("_UST", bound=UserString)
_MST = TypeVar("_MST", bound=MutableString)
class UserString(Sequence[UserString]):
@@ -13,21 +13,21 @@ class UserString(Sequence[UserString]):
def __hash__(self) -> int: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self: _UST, i: int) -> _UST: ...
def __getitem__(self: Self, i: int) -> Self: ...
@overload
def __getitem__(self: _UST, s: slice) -> _UST: ...
def __add__(self: _UST, other: Any) -> _UST: ...
def __radd__(self: _UST, other: Any) -> _UST: ...
def __mul__(self: _UST, other: int) -> _UST: ...
def __rmul__(self: _UST, other: int) -> _UST: ...
def __mod__(self: _UST, args: Any) -> _UST: ...
def capitalize(self: _UST) -> _UST: ...
def center(self: _UST, width: int, *args: Any) -> _UST: ...
def __getitem__(self: Self, s: slice) -> Self: ...
def __add__(self: Self, other: Any) -> Self: ...
def __radd__(self: Self, other: Any) -> Self: ...
def __mul__(self: Self, other: int) -> Self: ...
def __rmul__(self: Self, other: int) -> Self: ...
def __mod__(self: Self, args: Any) -> Self: ...
def capitalize(self: Self) -> Self: ...
def center(self: Self, width: int, *args: Any) -> Self: ...
def count(self, sub: int, start: int = ..., end: int = ...) -> int: ...
def decode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ...
def encode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ...
def decode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
def endswith(self, suffix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def expandtabs(self: _UST, tabsize: int = ...) -> _UST: ...
def expandtabs(self: Self, tabsize: int = ...) -> Self: ...
def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def isalpha(self) -> bool: ...
@@ -40,35 +40,35 @@ class UserString(Sequence[UserString]):
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def join(self, seq: Iterable[Text]) -> Text: ...
def ljust(self: _UST, width: int, *args: Any) -> _UST: ...
def lower(self: _UST) -> _UST: ...
def lstrip(self: _UST, chars: Text | None = ...) -> _UST: ...
def ljust(self: Self, width: int, *args: Any) -> Self: ...
def lower(self: Self) -> Self: ...
def lstrip(self: Self, chars: Text | None = ...) -> Self: ...
def partition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
def replace(self: _UST, old: Text, new: Text, maxsplit: int = ...) -> _UST: ...
def replace(self: Self, old: Text, new: Text, maxsplit: int = ...) -> Self: ...
def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def rjust(self: _UST, width: int, *args: Any) -> _UST: ...
def rjust(self: Self, width: int, *args: Any) -> Self: ...
def rpartition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
def rstrip(self: _UST, chars: Text | None = ...) -> _UST: ...
def rstrip(self: Self, chars: Text | None = ...) -> Self: ...
def split(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
def splitlines(self, keepends: int = ...) -> List[Text]: ...
def startswith(self, prefix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def strip(self: _UST, chars: Text | None = ...) -> _UST: ...
def swapcase(self: _UST) -> _UST: ...
def title(self: _UST) -> _UST: ...
def translate(self: _UST, *args: Any) -> _UST: ...
def upper(self: _UST) -> _UST: ...
def zfill(self: _UST, width: int) -> _UST: ...
def strip(self: Self, chars: Text | None = ...) -> Self: ...
def swapcase(self: Self) -> Self: ...
def title(self: Self) -> Self: ...
def translate(self: Self, *args: Any) -> Self: ...
def upper(self: Self) -> Self: ...
def zfill(self: Self, width: int) -> Self: ...
class MutableString(UserString, MutableSequence[MutableString]):
@overload
def __getitem__(self: _MST, i: int) -> _MST: ...
def __getitem__(self: Self, i: int) -> Self: ...
@overload
def __getitem__(self: _MST, s: slice) -> _MST: ...
def __getitem__(self: Self, s: slice) -> Self: ...
def __setitem__(self, index: int | slice, sub: Any) -> None: ...
def __delitem__(self, index: int | slice) -> None: ...
def immutable(self) -> UserString: ...
def __iadd__(self: _MST, other: Any) -> _MST: ...
def __iadd__(self: Self, other: Any) -> Self: ...
def __imul__(self, n: int) -> _MST: ...
def insert(self, index: int, value: Any) -> None: ...