diff --git a/stdlib/array.pyi b/stdlib/array.pyi index d9ca42de7..f4071834f 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Self from typing import BinaryIO, Generic, Iterable, MutableSequence, TypeVar, Union, overload from typing_extensions import Literal, SupportsIndex @@ -61,8 +62,8 @@ class array(MutableSequence[_T], Generic[_T]): def __add__(self, __x: array[_T]) -> array[_T]: ... def __ge__(self, __other: array[_T]) -> bool: ... def __gt__(self, __other: array[_T]) -> bool: ... - def __iadd__(self, __x: array[_T]) -> array[_T]: ... # type: ignore # Overrides MutableSequence - def __imul__(self, __n: int) -> array[_T]: ... + def __iadd__(self: Self, __x: array[_T]) -> Self: ... # type: ignore # Overrides MutableSequence + def __imul__(self: Self, __n: int) -> Self: ... def __le__(self, __other: array[_T]) -> bool: ... def __lt__(self, __other: array[_T]) -> bool: ... def __mul__(self, __n: int) -> array[_T]: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index e568ce6a7..b1ca2a3a4 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -645,10 +645,10 @@ class bytearray(MutableSequence[int], ByteString): 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 __iadd__(self: Self, __s: Iterable[int]) -> Self: ... def __mul__(self, __n: SupportsIndex) -> bytearray: ... def __rmul__(self, __n: SupportsIndex) -> bytearray: ... - def __imul__(self, __n: SupportsIndex) -> bytearray: ... + def __imul__(self: Self, __n: SupportsIndex) -> Self: ... def __mod__(self, __value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override] diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 83355dc3b..c6c40f608 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -263,10 +263,10 @@ class Counter(dict[_T, int], Generic[_T]): def __or__(self, other: Counter[_T]) -> Counter[_T]: ... # type: ignore[override] def __pos__(self) -> Counter[_T]: ... def __neg__(self) -> Counter[_T]: ... - def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ... - def __isub__(self, other: Counter[_T]) -> Counter[_T]: ... - def __iand__(self, other: Counter[_T]) -> Counter[_T]: ... - def __ior__(self, other: Counter[_T]) -> Counter[_T]: ... # type: ignore[override] + def __iadd__(self: Self, other: Counter[_T]) -> Self: ... + def __isub__(self: Self, other: Counter[_T]) -> Self: ... + def __iand__(self: Self, other: Counter[_T]) -> Self: ... + def __ior__(self: Self, other: Counter[_T]) -> Self: ... # type: ignore[override] if sys.version_info >= (3, 10): def total(self) -> int: ... diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index 324216b8b..94e3179cc 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -1,4 +1,5 @@ import datetime +from _typeshed import Self from typing import Iterable from dateutil.relativedelta import relativedelta @@ -19,9 +20,9 @@ class DateTimeRange: def __eq__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... def __add__(self, other: datetime.timedelta) -> DateTimeRange: ... - def __iadd__(self, other: datetime.timedelta) -> DateTimeRange: ... + def __iadd__(self: Self, other: datetime.timedelta) -> Self: ... def __sub__(self, other: datetime.timedelta) -> DateTimeRange: ... - def __isub__(self, other: datetime.timedelta) -> DateTimeRange: ... + def __isub__(self: Self, other: datetime.timedelta) -> Self: ... def __contains__(self, x: datetime.timedelta | DateTimeRange | str) -> bool: ... @property def start_datetime(self) -> datetime.datetime: ... diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 0a1603fb6..d4f65651a 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -1,6 +1,7 @@ import importlib.abc import types import zipimport +from _typeshed import Self from abc import ABCMeta from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, TypeVar, Union, overload @@ -53,7 +54,7 @@ class Environment: def remove(self, dist: Distribution) -> None: ... def can_add(self, dist: Distribution) -> bool: ... def __add__(self, other: Distribution | Environment) -> Environment: ... - def __iadd__(self, other: Distribution | Environment) -> Environment: ... + def __iadd__(self: Self, other: Distribution | Environment) -> Self: ... @overload def best_match(self, req: Requirement, working_set: WorkingSet) -> Distribution: ... @overload