diff --git a/stdlib/@python2/UserList.pyi b/stdlib/@python2/UserList.pyi index be4ebce5a..4dfc738a8 100644 --- a/stdlib/@python2/UserList.pyi +++ b/stdlib/@python2/UserList.pyi @@ -1,7 +1,7 @@ +from _typeshed import Self from typing import Iterable, List, MutableSequence, TypeVar, overload _T = TypeVar("_T") -_S = TypeVar("_S") class UserList(MutableSequence[_T]): data: List[_T] @@ -15,5 +15,5 @@ class UserList(MutableSequence[_T]): @overload def __getitem__(self, i: int) -> _T: ... @overload - def __getitem__(self: _S, s: slice) -> _S: ... + def __getitem__(self: Self, s: slice) -> Self: ... def sort(self) -> None: ... diff --git a/stdlib/@python2/UserString.pyi b/stdlib/@python2/UserString.pyi index f60dbe18f..123c1cb43 100644 --- a/stdlib/@python2/UserString.pyi +++ b/stdlib/@python2/UserString.pyi @@ -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: ... diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 532301014..f1a251406 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -1,7 +1,7 @@ # True and False are deliberately omitted because they are keywords in # Python 3, and stub files conform to Python 3 syntax. -from _typeshed import ReadableBuffer, SupportsKeysAndGetItem, SupportsWrite +from _typeshed import ReadableBuffer, Self, SupportsKeysAndGetItem, SupportsWrite from abc import ABCMeta from ast import mod from types import CodeType @@ -651,7 +651,7 @@ class list(MutableSequence[_T], Generic[_T]): def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, x: List[_T]) -> List[_T]: ... - def __iadd__(self: _S, x: Iterable[_T]) -> _S: ... + def __iadd__(self: Self, x: Iterable[_T]) -> Self: ... def __mul__(self, n: int) -> List[_T]: ... def __rmul__(self, n: int) -> List[_T]: ... def __contains__(self, o: object) -> bool: ... diff --git a/stdlib/@python2/_collections.pyi b/stdlib/@python2/_collections.pyi index 22ada07d0..964126548 100644 --- a/stdlib/@python2/_collections.pyi +++ b/stdlib/@python2/_collections.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from typing import Any, Callable, Dict, Generic, Iterator, TypeVar _K = TypeVar("_K") @@ -9,8 +10,8 @@ class defaultdict(Dict[_K, _V]): default_factory: None def __init__(self, __default_factory: Callable[[], _V] = ..., init: Any = ...) -> None: ... def __missing__(self, key: _K) -> _V: ... - def __copy__(self: _T) -> _T: ... - def copy(self: _T) -> _T: ... + def __copy__(self: Self) -> Self: ... + def copy(self: Self) -> Self: ... class deque(Generic[_T]): maxlen: int | None diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index fedbbe137..6abcac8be 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from mmap import mmap -from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, TypeVar, Union +from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, Union _bytearray_like = Union[bytearray, mmap] @@ -11,8 +11,6 @@ class BlockingIOError(IOError): class UnsupportedOperation(ValueError, IOError): ... -_T = TypeVar("_T") - class _IOBase(BinaryIO): @property def closed(self) -> bool: ... @@ -33,7 +31,7 @@ class _IOBase(BinaryIO): def writable(self) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__(self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ... - def __iter__(self: _T) -> _T: ... + def __iter__(self: Self) -> Self: ... # The parameter type of writelines[s]() is determined by that of write(): def writelines(self, lines: Iterable[bytes]) -> None: ... # The return type of readline[s]() and next() is determined by that of read(): @@ -141,7 +139,7 @@ class _TextIOBase(TextIO): def writelines(self, lines: Iterable[unicode]) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ... - def __iter__(self: _T) -> _T: ... + def __iter__(self: Self) -> Self: ... class StringIO(_TextIOBase): line_buffering: bool diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index f2cde7d67..a6ca20d57 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,15 +1,15 @@ +from _typeshed import Self from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar _S = TypeVar("_S") _T = TypeVar("_T") -_SelfT = TypeVar("_SelfT", bound=WeakSet[Any]) class WeakSet(MutableSet[_T], Generic[_T]): def __init__(self, data: Iterable[_T] | None = ...) -> None: ... def add(self, item: _T) -> None: ... def clear(self) -> None: ... def discard(self, item: _T) -> None: ... - def copy(self: _SelfT) -> _SelfT: ... + def copy(self: Self) -> Self: ... def pop(self) -> _T: ... def remove(self, item: _T) -> None: ... def update(self, other: Iterable[_T]) -> None: ... @@ -17,14 +17,14 @@ class WeakSet(MutableSet[_T], Generic[_T]): def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __ior__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... - def difference(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... - def __sub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def difference(self: Self, other: Iterable[_T]) -> Self: ... + def __sub__(self: Self, other: Iterable[_T]) -> Self: ... def difference_update(self, other: Iterable[_T]) -> None: ... - def __isub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... - def intersection(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... - def __and__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def __isub__(self: Self, other: Iterable[_T]) -> Self: ... + def intersection(self: Self, other: Iterable[_T]) -> Self: ... + def __and__(self: Self, other: Iterable[_T]) -> Self: ... def intersection_update(self, other: Iterable[_T]) -> None: ... - def __iand__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def __iand__(self: Self, other: Iterable[_T]) -> Self: ... def issubset(self, other: Iterable[_T]) -> bool: ... def __le__(self, other: Iterable[_T]) -> bool: ... def __lt__(self, other: Iterable[_T]) -> bool: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 532301014..f1a251406 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -1,7 +1,7 @@ # True and False are deliberately omitted because they are keywords in # Python 3, and stub files conform to Python 3 syntax. -from _typeshed import ReadableBuffer, SupportsKeysAndGetItem, SupportsWrite +from _typeshed import ReadableBuffer, Self, SupportsKeysAndGetItem, SupportsWrite from abc import ABCMeta from ast import mod from types import CodeType @@ -651,7 +651,7 @@ class list(MutableSequence[_T], Generic[_T]): def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, x: List[_T]) -> List[_T]: ... - def __iadd__(self: _S, x: Iterable[_T]) -> _S: ... + def __iadd__(self: Self, x: Iterable[_T]) -> Self: ... def __mul__(self, n: int) -> List[_T]: ... def __rmul__(self, n: int) -> List[_T]: ... def __contains__(self, o: object) -> bool: ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 81ee6f6ce..fa26410f9 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -1,16 +1,15 @@ import io -from _typeshed import ReadableBuffer, WriteableBuffer -from typing import IO, Any, Iterable, List, Text, TypeVar, Union +from _typeshed import ReadableBuffer, Self, WriteableBuffer +from typing import IO, Any, Iterable, List, Text, Union from typing_extensions import SupportsIndex _PathOrFile = Union[Text, IO[bytes]] -_T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... def decompress(data: bytes) -> bytes: ... class BZ2File(io.BufferedIOBase, IO[bytes]): - def __enter__(self: _T) -> _T: ... + def __enter__(self: Self) -> Self: ... def __init__(self, filename: _PathOrFile, mode: str = ..., buffering: Any | None = ..., compresslevel: int = ...) -> None: ... def read(self, size: int | None = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 1257b0cc9..8c1dce395 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from types import CodeType from typing import Any, Callable, Dict, Text, Tuple, TypeVar @@ -6,7 +7,6 @@ def runctx( statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... -_SelfT = TypeVar("_SelfT", bound=Profile) _T = TypeVar("_T") _Label = Tuple[str, int, str] @@ -21,8 +21,8 @@ class Profile: def dump_stats(self, file: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... - def run(self: _SelfT, cmd: str) -> _SelfT: ... - def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... + def run(self: Self, cmd: str) -> Self: ... + def runctx(self: Self, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> Self: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index a78351063..3ba91b373 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -1,4 +1,5 @@ import types +from _typeshed import Self from abc import abstractmethod from typing import ( IO, @@ -14,7 +15,6 @@ from typing import ( TextIO, Tuple, Type, - TypeVar, Union, overload, ) @@ -189,8 +189,6 @@ class BufferedIncrementalDecoder(IncrementalDecoder): def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> Tuple[_Decoded, int]: ... def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ... -_SW = TypeVar("_SW", bound=StreamWriter) - # TODO: it is not possible to specify the requirement that all other # attributes and methods are passed-through from the stream. class StreamWriter(Codec): @@ -199,12 +197,10 @@ class StreamWriter(Codec): def write(self, object: _Decoded) -> None: ... def writelines(self, list: Iterable[_Decoded]) -> None: ... def reset(self) -> None: ... - def __enter__(self: _SW) -> _SW: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... -_SR = TypeVar("_SR", bound=StreamReader) - class StreamReader(Codec): errors: str def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... @@ -212,13 +208,11 @@ class StreamReader(Codec): def readline(self, size: int | None = ..., keepends: bool = ...) -> _Decoded: ... def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[_Decoded]: ... def reset(self) -> None: ... - def __enter__(self: _SR) -> _SR: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __iter__(self) -> Iterator[_Decoded]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... -_T = TypeVar("_T", bound=StreamReaderWriter) - # Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing # and delegates attributes to the underlying binary stream with __getattr__. class StreamReaderWriter(TextIO): @@ -227,14 +221,14 @@ class StreamReaderWriter(TextIO): def readline(self, size: int | None = ...) -> _Decoded: ... def readlines(self, sizehint: int | None = ...) -> List[_Decoded]: ... def next(self) -> Text: ... - def __iter__(self: _T) -> _T: ... + def __iter__(self: Self) -> Self: ... # This actually returns None, but that's incompatible with the supertype def write(self, data: _Decoded) -> int: ... def writelines(self, list: Iterable[_Decoded]) -> None: ... def reset(self) -> None: ... # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str) -> Any: ... # These methods don't actually exist directly, but they are needed to satisfy the TextIO @@ -249,8 +243,6 @@ class StreamReaderWriter(TextIO): def tell(self) -> int: ... def writable(self) -> bool: ... -_SRT = TypeVar("_SRT", bound=StreamRecoder) - class StreamRecoder(BinaryIO): def __init__( self, @@ -265,12 +257,12 @@ class StreamRecoder(BinaryIO): def readline(self, size: int | None = ...) -> bytes: ... def readlines(self, sizehint: int | None = ...) -> List[bytes]: ... def next(self) -> bytes: ... - def __iter__(self: _SRT) -> _SRT: ... + def __iter__(self: Self) -> Self: ... def write(self, data: bytes) -> int: ... def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None def reset(self) -> None: ... def __getattr__(self, name: str) -> Any: ... - def __enter__(self: _SRT) -> _SRT: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO # interface. At runtime, they are delegated through __getattr__. diff --git a/stdlib/@python2/collections.pyi b/stdlib/@python2/collections.pyi index 5a2f73aed..36a9a48cf 100644 --- a/stdlib/@python2/collections.pyi +++ b/stdlib/@python2/collections.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from typing import ( AbstractSet, Any, @@ -28,7 +29,6 @@ from typing import ( Set = AbstractSet -_S = TypeVar("_S") _T = TypeVar("_T") _KT = TypeVar("_KT") _VT = TypeVar("_VT") @@ -61,7 +61,7 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): def __setitem__(self, i: int, x: _T) -> None: ... def __contains__(self, o: _T) -> bool: ... def __reversed__(self) -> Iterator[_T]: ... - def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ... + def __iadd__(self: Self, iterable: Iterable[_T]) -> Self: ... class Counter(Dict[_T, int], Generic[_T]): @overload @@ -70,7 +70,7 @@ class Counter(Dict[_T, int], Generic[_T]): def __init__(self, mapping: Mapping[_T, int]) -> None: ... @overload def __init__(self, iterable: Iterable[_T]) -> None: ... - def copy(self: _S) -> _S: ... + def copy(self: Self) -> Self: ... def elements(self) -> Iterator[_T]: ... def most_common(self, n: int | None = ...) -> List[Tuple[_T, int]]: ... @overload @@ -99,7 +99,7 @@ class Counter(Dict[_T, int], Generic[_T]): class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ... - def copy(self: _S) -> _S: ... + def copy(self: Self) -> Self: ... def __reversed__(self) -> Iterator[_KT]: ... class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): @@ -119,4 +119,4 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __missing__(self, key: _KT) -> _VT: ... - def copy(self: _S) -> _S: ... + def copy(self: Self) -> Self: ... diff --git a/stdlib/@python2/distutils/version.pyi b/stdlib/@python2/distutils/version.pyi index dd0969b86..1a0ea71c2 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from abc import abstractmethod from typing import Pattern, Text, Tuple, TypeVar @@ -8,7 +9,7 @@ class Version: @abstractmethod def __init__(self, vstring: Text | None = ...) -> None: ... @abstractmethod - def parse(self: _T, vstring: Text) -> _T: ... + def parse(self: Self, vstring: Text) -> Self: ... @abstractmethod def __str__(self) -> str: ... @abstractmethod @@ -19,7 +20,7 @@ class StrictVersion(Version): version: Tuple[int, int, int] prerelease: Tuple[Text, int] | None def __init__(self, vstring: Text | None = ...) -> None: ... - def parse(self: _T, vstring: Text) -> _T: ... + def parse(self: Self, vstring: Text) -> Self: ... def __str__(self) -> str: ... def __cmp__(self: _T, other: _T | str) -> bool: ... @@ -28,6 +29,6 @@ class LooseVersion(Version): vstring: Text version: Tuple[Text | int, ...] def __init__(self, vstring: Text | None = ...) -> None: ... - def parse(self: _T, vstring: Text) -> _T: ... + def parse(self: Self, vstring: Text) -> Self: ... def __str__(self) -> str: ... def __cmp__(self: _T, other: _T | str) -> bool: ... diff --git a/stdlib/@python2/lib2to3/pgen2/grammar.pyi b/stdlib/@python2/lib2to3/pgen2/grammar.pyi index 6ec97ce84..22799dd55 100644 --- a/stdlib/@python2/lib2to3/pgen2/grammar.pyi +++ b/stdlib/@python2/lib2to3/pgen2/grammar.pyi @@ -1,7 +1,6 @@ -from _typeshed import StrPath -from typing import Dict, List, Optional, Text, Tuple, TypeVar +from _typeshed import Self, StrPath +from typing import Dict, List, Optional, Text, Tuple -_P = TypeVar("_P") _Label = Tuple[int, Optional[Text]] _DFA = List[List[Tuple[int, int]]] _DFAS = Tuple[_DFA, Dict[int, int]] @@ -19,7 +18,7 @@ class Grammar: def __init__(self) -> None: ... def dump(self, filename: StrPath) -> None: ... def load(self, filename: StrPath) -> None: ... - def copy(self: _P) -> _P: ... + def copy(self: Self) -> Self: ... def report(self) -> None: ... opmap_raw: Text diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 27c648533..2a069128f 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from lib2to3.pgen2.grammar import Grammar from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union @@ -21,7 +22,7 @@ class Base: was_checked: bool def __eq__(self, other: Any) -> bool: ... def _eq(self: _P, other: _P) -> bool: ... - def clone(self: _P) -> _P: ... + def clone(self: Self) -> Self: ... def post_order(self) -> Iterator[_NL]: ... def pre_order(self) -> Iterator[_NL]: ... def replace(self, new: _NL | List[_NL]) -> None: ... diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 56545d3b8..4b1ac2cbf 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -1,9 +1,9 @@ import datetime import socket import ssl -from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, TypeVar, Union +from _typeshed import Self +from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, Union -_SelfT = TypeVar("_SelfT", bound=_NNTPBase) _File = Union[IO[bytes], bytes, str, None] class NNTPError(Exception): @@ -45,7 +45,7 @@ class _NNTPBase: nntp_implementation: str nntp_version: int def __init__(self, file: IO[bytes], host: str, readermode: bool | None = ..., timeout: float = ...) -> None: ... - def __enter__(self: _SelfT) -> _SelfT: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... def getwelcome(self) -> str: ... def getcapabilities(self) -> Dict[str, List[str]]: ... diff --git a/stdlib/@python2/profile.pyi b/stdlib/@python2/profile.pyi index 08e9b906d..cf9e9e547 100644 --- a/stdlib/@python2/profile.pyi +++ b/stdlib/@python2/profile.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from typing import Any, Callable, Dict, Text, Tuple, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... @@ -5,7 +6,6 @@ def runctx( statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... -_SelfT = TypeVar("_SelfT", bound=Profile) _T = TypeVar("_T") _Label = Tuple[str, int, str] @@ -20,7 +20,7 @@ class Profile: def dump_stats(self, file: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... - def run(self: _SelfT, cmd: str) -> _SelfT: ... - def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... + def run(self: Self, cmd: str) -> Self: ... + def runctx(self: Self, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> Self: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... def calibrate(self, m: int, verbose: int = ...) -> float: ... diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index cecd1e84e..7c8129b5d 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from cProfile import Profile as _cProfile from profile import Profile from typing import IO, Any, Dict, Iterable, List, Text, Tuple, TypeVar, Union, overload @@ -16,21 +17,21 @@ class Stats: def init(self, arg: None | str | Text | Profile | _cProfile) -> None: ... def load_stats(self, arg: None | str | Text | Profile | _cProfile) -> None: ... def get_top_level_stats(self) -> None: ... - def add(self: _T, *arg_list: None | str | Text | Profile | _cProfile | _T) -> _T: ... + def add(self: Self, *arg_list: None | str | Text | Profile | _cProfile | Self) -> Self: ... def dump_stats(self, filename: Text) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload - def sort_stats(self: _T, field: int) -> _T: ... + def sort_stats(self: Self, field: int) -> Self: ... @overload - def sort_stats(self: _T, *field: str) -> _T: ... - def reverse_order(self: _T) -> _T: ... - def strip_dirs(self: _T) -> _T: ... + def sort_stats(self: Self, *field: str) -> Self: ... + def reverse_order(self: Self) -> Self: ... + def strip_dirs(self: Self) -> Self: ... def calc_callees(self) -> None: ... def eval_print_amount(self, sel: _Selector, list: List[str], msg: str) -> Tuple[List[str], str]: ... def get_print_list(self, sel_list: Iterable[_Selector]) -> Tuple[int, List[str]]: ... - def print_stats(self: _T, *amount: _Selector) -> _T: ... - def print_callees(self: _T, *amount: _Selector) -> _T: ... - def print_callers(self: _T, *amount: _Selector) -> _T: ... + def print_stats(self: Self, *amount: _Selector) -> Self: ... + def print_callees(self: Self, *amount: _Selector) -> Self: ... + def print_callers(self: Self, *amount: _Selector) -> Self: ... def print_call_heading(self, name_size: int, column_title: str) -> None: ... def print_call_line(self, name_size: int, source: str, call_dict: Dict[str, Any], arrow: str = ...) -> None: ... def print_title(self) -> None: ... diff --git a/stdlib/@python2/sets.pyi b/stdlib/@python2/sets.pyi index d2b94ea44..5d1974a55 100644 --- a/stdlib/@python2/sets.pyi +++ b/stdlib/@python2/sets.pyi @@ -1,8 +1,8 @@ +from _typeshed import Self from typing import Any, Hashable, Iterable, Iterator, MutableMapping, TypeVar, Union _T = TypeVar("_T") _Setlike = Union[BaseSet[_T], Iterable[_T]] -_SelfT = TypeVar("_SelfT") class BaseSet(Iterable[_T]): def __init__(self) -> None: ... @@ -13,17 +13,17 @@ class BaseSet(Iterable[_T]): def __cmp__(self, other: Any) -> int: ... def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... - def copy(self: _SelfT) -> _SelfT: ... - def __copy__(self: _SelfT) -> _SelfT: ... - def __deepcopy__(self: _SelfT, memo: MutableMapping[int, BaseSet[_T]]) -> _SelfT: ... - def __or__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... - def union(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ... - def __and__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... - def intersection(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ... - def __xor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... - def symmetric_difference(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ... - def __sub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... - def difference(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ... + def copy(self: Self) -> Self: ... + def __copy__(self: Self) -> Self: ... + def __deepcopy__(self: Self, memo: MutableMapping[int, BaseSet[_T]]) -> Self: ... + def __or__(self: Self, other: BaseSet[_T]) -> Self: ... + def union(self: Self, other: _Setlike[_T]) -> Self: ... + def __and__(self: Self, other: BaseSet[_T]) -> Self: ... + def intersection(self: Self, other: _Setlike[Any]) -> Self: ... + def __xor__(self: Self, other: BaseSet[_T]) -> Self: ... + def symmetric_difference(self: Self, other: _Setlike[_T]) -> Self: ... + def __sub__(self: Self, other: BaseSet[_T]) -> Self: ... + def difference(self: Self, other: _Setlike[Any]) -> Self: ... def __contains__(self, element: Any) -> bool: ... def issubset(self, other: BaseSet[_T]) -> bool: ... def issuperset(self, other: BaseSet[_T]) -> bool: ... @@ -38,13 +38,13 @@ class ImmutableSet(BaseSet[_T], Hashable): class Set(BaseSet[_T]): def __init__(self, iterable: _Setlike[_T] | None = ...) -> None: ... - def __ior__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def __ior__(self: Self, other: BaseSet[_T]) -> Self: ... def union_update(self, other: _Setlike[_T]) -> None: ... - def __iand__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def __iand__(self: Self, other: BaseSet[_T]) -> Self: ... def intersection_update(self, other: _Setlike[Any]) -> None: ... - def __ixor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def __ixor__(self: Self, other: BaseSet[_T]) -> Self: ... def symmetric_difference_update(self, other: _Setlike[_T]) -> None: ... - def __isub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def __isub__(self: Self, other: BaseSet[_T]) -> Self: ... def difference_update(self, other: _Setlike[Any]) -> None: ... def update(self, iterable: _Setlike[_T]) -> None: ... def clear(self) -> None: ... diff --git a/stdlib/@python2/shlex.pyi b/stdlib/@python2/shlex.pyi index 89c28fc9b..aac3192a1 100644 --- a/stdlib/@python2/shlex.pyi +++ b/stdlib/@python2/shlex.pyi @@ -1,12 +1,11 @@ -from typing import IO, Any, List, Text, TypeVar +from _typeshed import Self +from typing import IO, Any, List, Text def split(s: str | None, comments: bool = ..., posix: bool = ...) -> List[str]: ... -_SLT = TypeVar("_SLT", bound=shlex) - class shlex: def __init__(self, instream: IO[Any] | Text = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ... - def __iter__(self: _SLT) -> _SLT: ... + def __iter__(self: Self) -> Self: ... def next(self) -> str: ... def get_token(self) -> str | None: ... def push_token(self, _str: str) -> None: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index 659dfd31b..4cc5ea8d3 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, List, Sequence, Text, Tuple, TypeVar, Union, overload +from _typeshed import Self +from typing import Any, Callable, Dict, List, Sequence, Text, Tuple, Union, overload # TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module. Canvas = Any @@ -199,8 +200,6 @@ class TPen(object): st = showturtle ht = hideturtle -_T = TypeVar("_T") - class RawTurtle(TPen, TNavigator): def __init__( self, canvas: Canvas | TurtleScreen | None = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ... @@ -209,7 +208,7 @@ class RawTurtle(TPen, TNavigator): def setundobuffer(self, size: int | None) -> None: ... def undobufferentries(self) -> int: ... def clear(self) -> None: ... - def clone(self: _T) -> _T: ... + def clone(self: Self) -> Self: ... @overload def shape(self, name: None = ...) -> str: ... @overload @@ -242,7 +241,7 @@ class RawTurtle(TPen, TNavigator): def end_poly(self) -> None: ... def get_poly(self) -> _PolygonCoords | None: ... def getscreen(self) -> TurtleScreen: ... - def getturtle(self: _T) -> _T: ... + def getturtle(self: Self) -> Self: ... getpen = getturtle def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index b50965bba..b209f7cfd 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -1,4 +1,5 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986 +from _typeshed import Self from abc import ABCMeta, abstractmethod from types import CodeType, FrameType, TracebackType @@ -462,11 +463,11 @@ class NamedTuple(Tuple[Any, ...]): @classmethod def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ... def _asdict(self) -> Dict[str, Any]: ... - def _replace(self: _T, **kwargs: Any) -> _T: ... + def _replace(self: Self, **kwargs: Any) -> Self: ... # Internal mypy fallback type for all typed dicts (does not exist at runtime) class _TypedDict(Mapping[str, object], metaclass=ABCMeta): - def copy(self: _T) -> _T: ... + def copy(self: Self) -> Self: ... # Using NoReturn so that only calls using mypy plugin hook that specialize the signature # can go through. def setdefault(self, k: NoReturn, default: object) -> object: ... diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index d946cc278..c9916e2a5 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -1,4 +1,5 @@ import abc +from _typeshed import Self from typing import ( TYPE_CHECKING as TYPE_CHECKING, Any, @@ -45,7 +46,7 @@ def IntVar(name: str) -> Any: ... # returns a new TypeVar # Internal mypy fallback type for all typed dicts (does not exist at runtime) class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): - def copy(self: _T) -> _T: ... + def copy(self: Self) -> Self: ... # Using NoReturn so that only calls using mypy plugin hook that specialize the signature # can go through. def setdefault(self, k: NoReturn, default: object) -> object: ... diff --git a/stdlib/@python2/urllib.pyi b/stdlib/@python2/urllib.pyi index f6bb555b9..538194d89 100644 --- a/stdlib/@python2/urllib.pyi +++ b/stdlib/@python2/urllib.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple, TypeVar +from _typeshed import Self +from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple def url2pathname(pathname: AnyStr) -> AnyStr: ... def pathname2url(pathname: AnyStr) -> AnyStr: ... @@ -77,15 +78,13 @@ class ftpwrapper: def file_close(self): ... def real_close(self): ... -_AIUT = TypeVar("_AIUT", bound=addbase) - class addbase: fp: Any def read(self, n: int = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... def readlines(self, hint: int = ...) -> List[bytes]: ... def fileno(self) -> int: ... # Optional[int], but that is rare - def __iter__(self: _AIUT) -> _AIUT: ... + def __iter__(self: Self) -> Self: ... def next(self) -> bytes: ... def __init__(self, fp) -> None: ... def close(self) -> None: ... diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index ed46ac456..10a0ddd03 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -1,10 +1,9 @@ import xml.dom -from typing import IO, Any, Text as _Text, TypeVar +from _typeshed import Self +from typing import IO, Any, Text as _Text from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader -_T = TypeVar("_T") - def parse(file: str | IO[Any], parser: XMLReader | None = ..., bufsize: int | None = ...): ... def parseString(string: bytes | _Text, parser: XMLReader | None = ...): ... def getDOMImplementation(features=...): ... @@ -32,7 +31,7 @@ class Node(xml.dom.Node): def setUserData(self, key, data, handler): ... childNodes: Any def unlink(self) -> None: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, et, ev, tb) -> None: ... class DocumentFragment(Node): diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 8c1823e4f..03eeff4be 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -1,5 +1,6 @@ import abc import sys +from _typeshed import Self as TypeshedSelf # see #6932 for why the alias cannot have a leading underscore from typing import ( TYPE_CHECKING as TYPE_CHECKING, Any, @@ -62,7 +63,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): __required_keys__: frozenset[str] __optional_keys__: frozenset[str] __total__: bool - def copy(self: _T) -> _T: ... + def copy(self: TypeshedSelf) -> TypeshedSelf: ... # Using NoReturn so that only calls using mypy plugin hook that specialize the signature # can go through. def setdefault(self, k: NoReturn, default: object) -> object: ... diff --git a/stubs/enum34/@python2/enum.pyi b/stubs/enum34/@python2/enum.pyi index 4bc061d1c..901d7d5fd 100644 --- a/stubs/enum34/@python2/enum.pyi +++ b/stubs/enum34/@python2/enum.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Self from abc import ABCMeta from typing import Any, Dict, Iterator, List, Mapping, Type, TypeVar, Union @@ -59,15 +60,15 @@ class Flag(Enum): def __repr__(self) -> str: ... def __str__(self) -> str: ... def __bool__(self) -> bool: ... - def __or__(self: _T, other: _T) -> _T: ... - def __and__(self: _T, other: _T) -> _T: ... - def __xor__(self: _T, other: _T) -> _T: ... - def __invert__(self: _T) -> _T: ... + def __or__(self: Self, other: Self) -> Self: ... + def __and__(self: Self, other: Self) -> Self: ... + def __xor__(self: Self, other: Self) -> Self: ... + def __invert__(self: Self) -> Self: ... class IntFlag(int, Flag): - def __or__(self: _T, other: Union[int, _T]) -> _T: ... - def __and__(self: _T, other: Union[int, _T]) -> _T: ... - def __xor__(self: _T, other: Union[int, _T]) -> _T: ... + def __or__(self: Self, other: Union[int, Self]) -> Self: ... + def __and__(self: Self, other: Union[int, Self]) -> Self: ... + def __xor__(self: Self, other: Union[int, Self]) -> Self: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__ diff --git a/stubs/futures/@python2/concurrent/futures/_base.pyi b/stubs/futures/@python2/concurrent/futures/_base.pyi index 40a986279..13c6bb229 100644 --- a/stubs/futures/@python2/concurrent/futures/_base.pyi +++ b/stubs/futures/@python2/concurrent/futures/_base.pyi @@ -1,4 +1,5 @@ import threading +from _typeshed import Self from abc import abstractmethod from logging import Logger from types import TracebackType @@ -48,7 +49,7 @@ class Executor: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...) -> Iterator[_T]: ... def shutdown(self, wait: bool = ...) -> None: ... - def __enter__(self: _T) -> _T: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ... def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ... diff --git a/stubs/ipaddress/@python2/ipaddress.pyi b/stubs/ipaddress/@python2/ipaddress.pyi index 5d0c7dd64..d623752b5 100644 --- a/stubs/ipaddress/@python2/ipaddress.pyi +++ b/stubs/ipaddress/@python2/ipaddress.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from typing import Any, Container, Generic, Iterable, Iterator, Optional, SupportsInt, Text, Tuple, TypeVar, overload # Undocumented length constants @@ -30,10 +31,10 @@ class _IPAddressBase: class _BaseAddress(_IPAddressBase, SupportsInt): def __init__(self, address: object) -> None: ... - def __add__(self: _T, other: int) -> _T: ... + def __add__(self: Self, other: int) -> Self: ... def __hash__(self) -> int: ... def __int__(self) -> int: ... - def __sub__(self: _T, other: int) -> _T: ... + def __sub__(self: Self, other: int) -> Self: ... @property def is_global(self) -> bool: ... @property @@ -87,7 +88,7 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): @property def prefixlen(self) -> int: ... def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ... - def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ... + def supernet(self: Self, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Self: ... @property def with_hostmask(self) -> Text: ... @property diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index ec2adea53..4155078dd 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -1,8 +1,10 @@ +from _typeshed import Self from datetime import date, datetime, timedelta from typing import SupportsFloat, TypeVar, overload from ._common import weekday +# We need the extra "Self" TypeVar to avoid overlapping __add__/__radd__ complaints from mypy _SelfT = TypeVar("_SelfT", bound=relativedelta) _DateT = TypeVar("_DateT", date, datetime) # Work around attribute and type having the same name. @@ -61,37 +63,37 @@ class relativedelta(object): def weeks(self) -> int: ... @weeks.setter def weeks(self, value: int) -> None: ... - def normalized(self: _SelfT) -> _SelfT: ... + def normalized(self: Self) -> Self: ... # TODO: use Union when mypy will handle it properly in overloaded operator # methods (#2129, #1442, #1264 in mypy) @overload - def __add__(self: _SelfT, other: relativedelta) -> _SelfT: ... + def __add__(self: _SelfT, other: relativedelta) -> _SelfT: ... # noqa: Y019 @overload - def __add__(self: _SelfT, other: timedelta) -> _SelfT: ... + def __add__(self: _SelfT, other: timedelta) -> _SelfT: ... # noqa: Y019 @overload def __add__(self, other: _DateT) -> _DateT: ... @overload - def __radd__(self: _SelfT, other: relativedelta) -> _SelfT: ... + def __radd__(self: _SelfT, other: relativedelta) -> _SelfT: ... # noqa: Y019 @overload - def __radd__(self: _SelfT, other: timedelta) -> _SelfT: ... + def __radd__(self: _SelfT, other: timedelta) -> _SelfT: ... # noqa: Y019 @overload def __radd__(self, other: _DateT) -> _DateT: ... @overload - def __rsub__(self: _SelfT, other: relativedelta) -> _SelfT: ... + def __rsub__(self: Self, other: relativedelta) -> Self: ... @overload - def __rsub__(self: _SelfT, other: timedelta) -> _SelfT: ... + def __rsub__(self: Self, other: timedelta) -> Self: ... @overload def __rsub__(self, other: _DateT) -> _DateT: ... - def __sub__(self: _SelfT, other: relativedelta) -> _SelfT: ... - def __neg__(self: _SelfT) -> _SelfT: ... + def __sub__(self: Self, other: relativedelta) -> Self: ... + def __neg__(self: Self) -> Self: ... def __bool__(self) -> bool: ... def __nonzero__(self) -> bool: ... - def __mul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... - def __rmul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... + def __mul__(self: Self, other: SupportsFloat) -> Self: ... + def __rmul__(self: Self, other: SupportsFloat) -> Self: ... def __eq__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... - def __div__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... - def __truediv__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... + def __div__(self: Self, other: SupportsFloat) -> Self: ... + def __truediv__(self: Self, other: SupportsFloat) -> Self: ... def __repr__(self) -> str: ... - def __abs__(self: _SelfT) -> _SelfT: ... + def __abs__(self: Self) -> Self: ... def __hash__(self) -> int: ...