From 2288a0fa822319f85c63ed71b67c25aaec5c7520 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 17:56:01 +0000 Subject: [PATCH 1/8] Remove many redundant method definitions --- stdlib/asyncio/events.pyi | 1 - stdlib/asyncio/futures.pyi | 1 - stdlib/asyncio/proactor_events.pyi | 1 - stdlib/asyncio/queues.pyi | 2 -- stdlib/asyncio/tasks.pyi | 1 - stdlib/asyncio/windows_events.pyi | 1 - stdlib/asyncio/windows_utils.pyi | 1 - stdlib/builtins.pyi | 28 --------------------------- stdlib/calendar.pyi | 2 -- stdlib/cgi.pyi | 2 -- stdlib/collections/__init__.pyi | 1 - stdlib/concurrent/futures/process.pyi | 2 -- stdlib/decimal.pyi | 2 -- stdlib/dis.pyi | 1 - stdlib/email/charset.pyi | 1 - stdlib/email/header.pyi | 1 - stdlib/email/headerregistry.pyi | 2 -- stdlib/email/message.pyi | 1 - stdlib/enum.pyi | 4 ---- stdlib/http/cookiejar.pyi | 2 -- stdlib/modulefinder.pyi | 1 - stdlib/msilib/__init__.pyi | 1 - stdlib/multiprocessing/managers.pyi | 2 -- stdlib/typing.pyi | 1 - stdlib/weakref.pyi | 2 -- stdlib/zipfile.pyi | 1 - 26 files changed, 65 deletions(-) diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 25b3846dee28..7cbc086b476b 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -32,7 +32,6 @@ class Handle: ) -> None: ... else: def __init__(self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ... - def __repr__(self) -> str: ... def cancel(self) -> None: ... def _run(self) -> None: ... if sys.version_info >= (3, 7): diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index 9788123f427e..3ec16f28850e 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -34,7 +34,6 @@ class Future(Awaitable[_T], Iterable[_T]): _blocking = False _log_traceback = False def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ... - def __repr__(self) -> str: ... def __del__(self) -> None: ... if sys.version_info >= (3, 7): def get_loop(self) -> AbstractEventLoop: ... diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 3c5182a39642..64c65d847fcf 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -21,7 +21,6 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr extra: Mapping[Any, Any] | None = ..., server: events.AbstractServer | None = ..., ) -> None: ... - def __repr__(self) -> str: ... if sys.version_info >= (3, 8): def __del__(self, _warn: _WarnCallbackProtocol = ...) -> None: ... else: diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index aff4af727b08..994268f54f0a 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -15,8 +15,6 @@ class Queue(Generic[_T]): def _init(self, maxsize: int) -> None: ... def _get(self) -> _T: ... def _put(self, item: _T) -> None: ... - def __repr__(self) -> str: ... - def __str__(self) -> str: ... def _format(self) -> str: ... def qsize(self) -> int: ... @property diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 4671b7787f56..c1c073895650 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -265,7 +265,6 @@ class Task(Future[_T], Generic[_T]): def __init__( self, coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, loop: AbstractEventLoop = ... ) -> None: ... - def __repr__(self) -> str: ... if sys.version_info >= (3, 8): def get_coro(self) -> Generator[_TaskYieldType, None, _T] | Awaitable[_T]: ... def get_name(self) -> str: ... diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 1bb49c9650e4..e43a0eda8083 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -41,7 +41,6 @@ if sys.platform == "win32": ) -> list[PipeServer]: ... class IocpProactor: def __init__(self, concurrency: int = ...) -> None: ... - def __repr__(self) -> str: ... def __del__(self) -> None: ... def set_loop(self, loop: events.AbstractEventLoop) -> None: ... def select(self, timeout: int | None = ...) -> list[futures.Future[Any]]: ... diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index 5d07362faf9d..3c96b76fc4a1 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -16,7 +16,6 @@ if sys.platform == "win32": def pipe(*, duplex: bool = ..., overlapped: tuple[bool, bool] = ..., bufsize: int = ...) -> tuple[int, int]: ... class PipeHandle: def __init__(self, handle: int) -> None: ... - def __repr__(self) -> str: ... if sys.version_info >= (3, 8): def __del__(self, _warn: _WarnFunction = ...) -> None: ... else: diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 5abfbd953e78..f704d1934c51 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -255,13 +255,10 @@ class int: def __floor__(self) -> int: ... def __round__(self, __ndigits: SupportsIndex = ...) -> int: ... def __getnewargs__(self) -> tuple[int]: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: int) -> bool: ... def __le__(self, __x: int) -> bool: ... def __gt__(self, __x: int) -> bool: ... def __ge__(self, __x: int) -> bool: ... - def __str__(self) -> str: ... def __float__(self) -> float: ... def __int__(self) -> int: ... def __abs__(self) -> int: ... @@ -311,15 +308,12 @@ class float: def __round__(self, __ndigits: None = ...) -> int: ... @overload def __round__(self, __ndigits: SupportsIndex) -> float: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: float) -> bool: ... def __le__(self, __x: float) -> bool: ... def __gt__(self, __x: float) -> bool: ... def __ge__(self, __x: float) -> bool: ... def __neg__(self) -> float: ... def __pos__(self) -> float: ... - def __str__(self) -> str: ... def __int__(self) -> int: ... def __float__(self) -> float: ... def __abs__(self) -> float: ... @@ -346,11 +340,8 @@ class complex: def __rmul__(self, __x: complex) -> complex: ... def __rpow__(self, __x: complex, __mod: None = ...) -> complex: ... def __rtruediv__(self, __x: complex) -> complex: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... def __neg__(self) -> complex: ... def __pos__(self) -> complex: ... - def __str__(self) -> str: ... def __abs__(self) -> float: ... def __hash__(self) -> int: ... def __bool__(self) -> bool: ... @@ -429,7 +420,6 @@ class str(Sequence[str]): def __add__(self, __s: str) -> str: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: str) -> bool: ... # type: ignore[override] - def __eq__(self, __x: object) -> bool: ... def __ge__(self, __x: str) -> bool: ... def __getitem__(self, __i: SupportsIndex | slice) -> str: ... def __gt__(self, __x: str) -> bool: ... @@ -440,10 +430,7 @@ class str(Sequence[str]): def __lt__(self, __x: str) -> bool: ... def __mod__(self, __x: Any) -> str: ... def __mul__(self, __n: SupportsIndex) -> str: ... - def __ne__(self, __x: object) -> bool: ... - def __repr__(self) -> str: ... def __rmul__(self, n: SupportsIndex) -> str: ... - def __str__(self) -> str: ... def __getnewargs__(self) -> tuple[str]: ... class bytes(ByteString): @@ -525,8 +512,6 @@ class bytes(ByteString): def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... def __hash__(self) -> int: ... @overload def __getitem__(self, __i: SupportsIndex) -> int: ... @@ -538,8 +523,6 @@ class bytes(ByteString): def __mod__(self, __value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override] - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: bytes) -> bool: ... def __le__(self, __x: bytes) -> bool: ... def __gt__(self, __x: bytes) -> bool: ... @@ -629,8 +612,6 @@ class bytearray(MutableSequence[int], ByteString): def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... __hash__: None # type: ignore[assignment] @overload def __getitem__(self, __i: SupportsIndex) -> int: ... @@ -649,8 +630,6 @@ class bytearray(MutableSequence[int], ByteString): def __mod__(self, __value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override] - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: bytes) -> bool: ... def __le__(self, __x: bytes) -> bool: ... def __gt__(self, __x: bytes) -> bool: ... @@ -807,7 +786,6 @@ class list(MutableSequence[_T], Generic[_T]): def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... - def __str__(self) -> str: ... __hash__: None # type: ignore[assignment] @overload def __getitem__(self, __i: SupportsIndex) -> _T: ... @@ -867,7 +845,6 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __iter__(self) -> Iterator[_KT]: ... if sys.version_info >= (3, 8): def __reversed__(self) -> Iterator[_KT]: ... - def __str__(self) -> str: ... __hash__: None # type: ignore[assignment] if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... @@ -895,7 +872,6 @@ class set(MutableSet[_T], Generic[_T]): def __len__(self) -> int: ... def __contains__(self, __o: object) -> bool: ... def __iter__(self) -> Iterator[_T]: ... - def __str__(self) -> str: ... def __and__(self, __s: AbstractSet[object]) -> set[_T]: ... def __iand__(self, __s: AbstractSet[object]) -> set[_T]: ... def __or__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ... @@ -925,7 +901,6 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]): def __len__(self) -> int: ... def __contains__(self, __o: object) -> bool: ... def __iter__(self) -> Iterator[_T_co]: ... - def __str__(self) -> str: ... def __and__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... def __or__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... def __sub__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... @@ -965,7 +940,6 @@ class range(Sequence[int]): def __getitem__(self, __i: SupportsIndex) -> int: ... @overload def __getitem__(self, __s: slice) -> range: ... - def __repr__(self) -> str: ... def __reversed__(self) -> Iterator[int]: ... class property: @@ -1526,8 +1500,6 @@ class BaseException: if sys.version_info >= (3, 11): __note__: str | None def __init__(self, *args: object) -> None: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... def with_traceback(self: _TBE, __tb: TracebackType | None) -> _TBE: ... class GeneratorExit(BaseException): ... diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 86466d0cd846..108356610322 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -35,11 +35,9 @@ _LocaleType = tuple[Optional[str], Optional[str]] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... - def __str__(self) -> str: ... class IllegalWeekdayError(ValueError): def __init__(self, weekday: int) -> None: ... - def __str__(self) -> str: ... def isleap(year: int) -> bool: ... def leapdays(y1: int, y2: int) -> int: ... diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index c2c3ac261010..8eee5c69504d 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -53,7 +53,6 @@ class MiniFieldStorage: name: Any value: Any def __init__(self, name: Any, value: Any) -> None: ... - def __repr__(self) -> str: ... _list = list @@ -96,7 +95,6 @@ class FieldStorage: ) -> None: ... def __enter__(self: _T) -> _T: ... def __exit__(self, *args: Any) -> None: ... - def __repr__(self) -> str: ... def __iter__(self) -> Iterator[str]: ... def __getitem__(self, key: str) -> Any: ... def getvalue(self, key: str, default: Any = ...) -> Any: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 2c30602da48f..c1a046949f83 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -200,7 +200,6 @@ class deque(MutableSequence[_T], Generic[_T]): def rotate(self, __n: int = ...) -> None: ... def __copy__(self: _S) -> _S: ... def __len__(self) -> int: ... - def __str__(self) -> str: ... # These methods of deque don't take slices, unlike MutableSequence, hence the type: ignores def __getitem__(self, __index: SupportsIndex) -> _T: ... # type: ignore[override] def __setitem__(self, __i: SupportsIndex, __x: _T) -> None: ... # type: ignore[override] diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index 6435901a8f13..31df900b8126 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -31,13 +31,11 @@ _MAX_WINDOWS_WORKERS: int class _RemoteTraceback(Exception): tb: str def __init__(self, tb: TracebackType) -> None: ... - def __str__(self) -> str: ... class _ExceptionWithTraceback: exc: BaseException tb: TracebackType def __init__(self, exc: BaseException, tb: TracebackType) -> None: ... - def __reduce__(self) -> str | tuple[Any, ...]: ... def _rebuild_exc(exc: Exception, tb: str) -> Exception: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 1bb81ab20da9..82f914f634ec 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -62,7 +62,6 @@ class Decimal: def __abs__(self) -> Decimal: ... def __add__(self, __other: _Decimal) -> Decimal: ... def __divmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ... - def __eq__(self, __other: object) -> bool: ... def __floordiv__(self, __other: _Decimal) -> Decimal: ... def __ge__(self, __other: _ComparableNum) -> bool: ... def __gt__(self, __other: _ComparableNum) -> bool: ... @@ -80,7 +79,6 @@ class Decimal: def __rmul__(self, __other: _Decimal) -> Decimal: ... def __rsub__(self, __other: _Decimal) -> Decimal: ... def __rtruediv__(self, __other: _Decimal) -> Decimal: ... - def __str__(self) -> str: ... def __sub__(self, __other: _Decimal) -> Decimal: ... def __truediv__(self, __other: _Decimal) -> Decimal: ... def remainder_near(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index ac0632d25c9c..15b44c96fbbd 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -38,7 +38,6 @@ class Bytecode: first_line: int def __init__(self, x: _HaveCodeOrStringType, *, first_line: int | None = ..., current_offset: int | None = ...) -> None: ... def __iter__(self) -> Iterator[Instruction]: ... - def __repr__(self) -> str: ... def info(self) -> str: ... def dis(self) -> str: ... @classmethod diff --git a/stdlib/email/charset.pyi b/stdlib/email/charset.pyi index 4bf5d11690eb..298b763540db 100644 --- a/stdlib/email/charset.pyi +++ b/stdlib/email/charset.pyi @@ -17,7 +17,6 @@ class Charset: def header_encode(self, string: str) -> str: ... def header_encode_lines(self, string: str, maxlengths: Iterator[int]) -> list[str]: ... def body_encode(self, string: str) -> str: ... - def __str__(self) -> str: ... def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... diff --git a/stdlib/email/header.pyi b/stdlib/email/header.pyi index 4bebd50c45e4..4490c16a4eb6 100644 --- a/stdlib/email/header.pyi +++ b/stdlib/email/header.pyi @@ -13,7 +13,6 @@ class Header: ) -> None: ... def append(self, s: bytes | str, charset: Charset | str | None = ..., errors: str = ...) -> None: ... def encode(self, splitchars: str = ..., maxlinelen: int | None = ..., linesep: str = ...) -> str: ... - def __str__(self) -> str: ... def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 962571eb7a7a..b84acab18ffe 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -159,7 +159,6 @@ class Address: def __init__( self, display_name: str = ..., username: str | None = ..., domain: str | None = ..., addr_spec: str | None = ... ) -> None: ... - def __str__(self) -> str: ... class Group: @property @@ -167,4 +166,3 @@ class Group: @property def addresses(self) -> tuple[Address, ...]: ... def __init__(self, display_name: str | None = ..., addresses: Iterable[Address] | None = ...) -> None: ... - def __str__(self) -> str: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 7d5eb4500d8f..5ce11e3d807e 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -17,7 +17,6 @@ class Message: preamble: str | None epilogue: str | None defects: list[MessageDefect] - def __str__(self) -> str: ... def is_multipart(self) -> bool: ... def set_unixfrom(self, unixfrom: str) -> None: ... def get_unixfrom(self) -> str | None: ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index 49f7bda4ee8e..b10b64546cb5 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -113,8 +113,6 @@ class Enum(metaclass=EnumMeta): @staticmethod def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: ... def __new__(cls: type[_T], value: object) -> _T: ... - def __repr__(self) -> str: ... - def __str__(self) -> str: ... def __dir__(self) -> list[str]: ... def __format__(self, format_spec: str) -> str: ... def __hash__(self) -> Any: ... @@ -159,8 +157,6 @@ class Flag(Enum): @types.DynamicClassAttribute def value(self) -> int: ... def __contains__(self: _T, other: _T) -> bool: ... - 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: ... diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 6bfa7f385e69..1b4deb9b2ca1 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -27,8 +27,6 @@ class CookieJar(Iterable[Cookie]): def clear_expired_cookies(self) -> None: ... # undocumented def __iter__(self) -> Iterator[Cookie]: ... def __len__(self) -> int: ... - def __repr__(self) -> str: ... - def __str__(self) -> str: ... class FileCookieJar(CookieJar): filename: str diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index 3e7694ccffc9..4a1783efefd1 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -19,7 +19,6 @@ def ReplacePackage(oldname: str, newname: str) -> None: ... class Module: # undocumented def __init__(self, name: str, file: str | None = ..., path: str | None = ...) -> None: ... - def __repr__(self) -> str: ... class ModuleFinder: diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 5933433ac00c..ba94e861f938 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -95,7 +95,6 @@ if sys.platform == "win32": name: str def __init__(self, fname: str) -> None: ... - def __repr__(self) -> str: ... class Feature: id: str diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 79310614efc1..c115a32520ef 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -23,7 +23,6 @@ _VT = TypeVar("_VT") class Namespace: def __init__(self, **kwds: Any) -> None: ... def __getattr__(self, __name: str) -> Any: ... - def __setattr__(self, __name: str, __value: Any) -> None: ... _Namespace = Namespace @@ -32,7 +31,6 @@ class Token: address: tuple[str | bytes, int] id: str | bytes | int | None def __init__(self, typeid: bytes | str | None, address: tuple[str | bytes, int], id: str | bytes | int | None) -> None: ... - def __repr__(self) -> str: ... def __getstate__(self) -> tuple[str | bytes | None, tuple[str | bytes, int], str | bytes | int | None]: ... def __setstate__(self, state: tuple[str | bytes | None, tuple[str | bytes, int], str | bytes | int | None]) -> None: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 8d9b20bf9a0d..925ade3d6859 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -738,7 +738,6 @@ if sys.version_info >= (3, 7): def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ... def __eq__(self, other: Any) -> bool: ... def __hash__(self) -> int: ... - def __repr__(self) -> str: ... if sys.version_info >= (3, 11): def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 363f939a6761..53f5680e3cda 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -33,7 +33,6 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): def __delitem__(self, v: _KT) -> None: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... - def __str__(self) -> str: ... def copy(self) -> WeakValueDictionary[_KT, _VT]: ... # These are incompatible with Mapping def keys(self) -> Iterator[_KT]: ... # type: ignore[override] @@ -64,7 +63,6 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): def __delitem__(self, v: _KT) -> None: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... - def __str__(self) -> str: ... def copy(self) -> WeakKeyDictionary[_KT, _VT]: ... # These are incompatible with Mapping def keys(self) -> Iterator[_KT]: ... # type: ignore[override] diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 4244229a1ad7..a0a968ac94b0 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -98,7 +98,6 @@ class ZipExtFile(io.BufferedIOBase): ) -> None: ... def read(self, n: int | None = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore[override] - def __repr__(self) -> str: ... def peek(self, n: int = ...) -> bytes: ... def read1(self, n: int | None) -> bytes: ... # type: ignore[override] if sys.version_info >= (3, 7): From d1a47f987b21be921af50b98a87c2118a844e619 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 18:09:22 +0000 Subject: [PATCH 2/8] Delete a few more --- stdlib/datetime.pyi | 2 -- stdlib/decimal.pyi | 1 - stdlib/multiprocessing/dummy/__init__.pyi | 1 - 3 files changed, 4 deletions(-) diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 6400fb0e6fd6..05464e63f888 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -57,7 +57,6 @@ class date: def day(self) -> int: ... def ctime(self) -> str: ... def strftime(self, __format: str) -> str: ... - def __format__(self, __fmt: str) -> str: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... def toordinal(self) -> int: ... @@ -129,7 +128,6 @@ class time: @classmethod def fromisoformat(cls: type[_S], __time_string: str) -> _S: ... def strftime(self, __format: str) -> str: ... - def __format__(self, __fmt: str) -> str: ... def utcoffset(self) -> timedelta | None: ... def tzname(self) -> str | None: ... def dst(self) -> timedelta | None: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 82f914f634ec..0928e5d6c846 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -181,7 +181,6 @@ class Context: ) -> None: ... # __setattr__() only allows to set a specific set of attributes, # already defined above. - def __delattr__(self, __name: str) -> None: ... def __reduce__(self) -> tuple[type[Context], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... def clear_traps(self) -> None: ... diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index b4d1c8404d8d..76120a5ad412 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -33,7 +33,6 @@ Process = DummyProcess class Namespace: def __init__(self, **kwds: Any) -> None: ... def __getattr__(self, __name: str) -> Any: ... - def __setattr__(self, __name: str, __value: Any) -> None: ... class Value: _typecode: Any From 3d3937b914501b2354894f06f4579b639ed2baf9 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 18:26:45 +0000 Subject: [PATCH 3/8] Address review --- stdlib/multiprocessing/dummy/__init__.pyi | 1 + stdlib/multiprocessing/managers.pyi | 1 + 2 files changed, 2 insertions(+) diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index 76120a5ad412..b4d1c8404d8d 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -33,6 +33,7 @@ Process = DummyProcess class Namespace: def __init__(self, **kwds: Any) -> None: ... def __getattr__(self, __name: str) -> Any: ... + def __setattr__(self, __name: str, __value: Any) -> None: ... class Value: _typecode: Any diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index c115a32520ef..42853dfd31d5 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -23,6 +23,7 @@ _VT = TypeVar("_VT") class Namespace: def __init__(self, **kwds: Any) -> None: ... def __getattr__(self, __name: str) -> Any: ... + def __setattr__(self, __name: str, __value: Any) -> None: ... _Namespace = Namespace From c6aee27c837768eee4269c63c278b9fe8c500d3f Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 18:38:50 +0000 Subject: [PATCH 4/8] Add some more methods back --- stdlib/datetime.pyi | 4 ++++ stdlib/decimal.pyi | 2 ++ 2 files changed, 6 insertions(+) diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 05464e63f888..f1decdcae1fb 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -57,6 +57,8 @@ class date: def day(self) -> int: ... def ctime(self) -> str: ... def strftime(self, __format: str) -> str: ... + # has the same signature as `object.__format__`, but appears to be special-cased by mypy + def __format__(self, __fmt: str) -> str: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... def toordinal(self) -> int: ... @@ -128,6 +130,8 @@ class time: @classmethod def fromisoformat(cls: type[_S], __time_string: str) -> _S: ... def strftime(self, __format: str) -> str: ... + # has the same signature as `object.__format__`, but appears to be special-cased by mypy + def __format__(self, __fmt: str) -> str: ... def utcoffset(self) -> timedelta | None: ... def tzname(self) -> str | None: ... def dst(self) -> timedelta | None: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 0928e5d6c846..6e725299b683 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -62,6 +62,8 @@ class Decimal: def __abs__(self) -> Decimal: ... def __add__(self, __other: _Decimal) -> Decimal: ... def __divmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ... + # has the same signature as `object.__eq__`, but appears to be special-cased by mypy + def __eq__(self, __other: object) -> bool: ... def __floordiv__(self, __other: _Decimal) -> Decimal: ... def __ge__(self, __other: _ComparableNum) -> bool: ... def __gt__(self, __other: _ComparableNum) -> bool: ... From 7cb8c8627409b4d77f985663dc2266584cfee05d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 18:55:02 +0000 Subject: [PATCH 5/8] Restore more methods --- stdlib/builtins.pyi | 12 ++++++++++++ stdlib/datetime.pyi | 2 -- stdlib/decimal.pyi | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index f704d1934c51..c7b9c29f0bcf 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -255,6 +255,8 @@ class int: def __floor__(self) -> int: ... def __round__(self, __ndigits: SupportsIndex = ...) -> int: ... def __getnewargs__(self) -> tuple[int]: ... + def __eq__(self, __x: object) -> bool: ... + def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: int) -> bool: ... def __le__(self, __x: int) -> bool: ... def __gt__(self, __x: int) -> bool: ... @@ -308,6 +310,8 @@ class float: def __round__(self, __ndigits: None = ...) -> int: ... @overload def __round__(self, __ndigits: SupportsIndex) -> float: ... + def __eq__(self, __x: object) -> bool: ... + def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: float) -> bool: ... def __le__(self, __x: float) -> bool: ... def __gt__(self, __x: float) -> bool: ... @@ -335,6 +339,8 @@ class complex: def __mul__(self, __x: complex) -> complex: ... def __pow__(self, __x: complex, mod: None = ...) -> complex: ... def __truediv__(self, __x: complex) -> complex: ... + def __eq__(self, __x: object) -> bool: ... + def __ne__(self, __x: object) -> bool: ... def __radd__(self, __x: complex) -> complex: ... def __rsub__(self, __x: complex) -> complex: ... def __rmul__(self, __x: complex) -> complex: ... @@ -420,6 +426,7 @@ class str(Sequence[str]): def __add__(self, __s: str) -> str: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: str) -> bool: ... # type: ignore[override] + def __eq__(self, __x: object) -> bool: ... def __ge__(self, __x: str) -> bool: ... def __getitem__(self, __i: SupportsIndex | slice) -> str: ... def __gt__(self, __x: str) -> bool: ... @@ -430,6 +437,7 @@ class str(Sequence[str]): def __lt__(self, __x: str) -> bool: ... def __mod__(self, __x: Any) -> str: ... def __mul__(self, __n: SupportsIndex) -> str: ... + def __ne__(self, __x: object) -> bool: ... def __rmul__(self, n: SupportsIndex) -> str: ... def __getnewargs__(self) -> tuple[str]: ... @@ -523,6 +531,8 @@ class bytes(ByteString): def __mod__(self, __value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override] + def __eq__(self, __x: object) -> bool: ... + def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: bytes) -> bool: ... def __le__(self, __x: bytes) -> bool: ... def __gt__(self, __x: bytes) -> bool: ... @@ -630,6 +640,8 @@ class bytearray(MutableSequence[int], ByteString): def __mod__(self, __value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, __o: SupportsIndex | bytes) -> bool: ... # type: ignore[override] + def __eq__(self, __x: object) -> bool: ... + def __ne__(self, __x: object) -> bool: ... def __lt__(self, __x: bytes) -> bool: ... def __le__(self, __x: bytes) -> bool: ... def __gt__(self, __x: bytes) -> bool: ... diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index f1decdcae1fb..6400fb0e6fd6 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -57,7 +57,6 @@ class date: def day(self) -> int: ... def ctime(self) -> str: ... def strftime(self, __format: str) -> str: ... - # has the same signature as `object.__format__`, but appears to be special-cased by mypy def __format__(self, __fmt: str) -> str: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... @@ -130,7 +129,6 @@ class time: @classmethod def fromisoformat(cls: type[_S], __time_string: str) -> _S: ... def strftime(self, __format: str) -> str: ... - # has the same signature as `object.__format__`, but appears to be special-cased by mypy def __format__(self, __fmt: str) -> str: ... def utcoffset(self) -> timedelta | None: ... def tzname(self) -> str | None: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 6e725299b683..1034ac2249d9 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -183,6 +183,7 @@ class Context: ) -> None: ... # __setattr__() only allows to set a specific set of attributes, # already defined above. + def __delattr__(self, __name: str) -> None: ... def __reduce__(self) -> tuple[type[Context], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... def clear_traps(self) -> None: ... From 7fcb24aaf3770ab731f03e132aa5fe665a9f3502 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 18:57:20 +0000 Subject: [PATCH 6/8] Update decimal.pyi --- stdlib/decimal.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 1034ac2249d9..0fce0cb5aed1 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -62,7 +62,6 @@ class Decimal: def __abs__(self) -> Decimal: ... def __add__(self, __other: _Decimal) -> Decimal: ... def __divmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ... - # has the same signature as `object.__eq__`, but appears to be special-cased by mypy def __eq__(self, __other: object) -> bool: ... def __floordiv__(self, __other: _Decimal) -> Decimal: ... def __ge__(self, __other: _ComparableNum) -> bool: ... From 1b021f097bb6d3faae96e46e97489056fb3be59c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 18:58:08 +0000 Subject: [PATCH 7/8] Update builtins.pyi --- stdlib/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index c7b9c29f0bcf..e648b96c672e 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -339,13 +339,13 @@ class complex: def __mul__(self, __x: complex) -> complex: ... def __pow__(self, __x: complex, mod: None = ...) -> complex: ... def __truediv__(self, __x: complex) -> complex: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... def __radd__(self, __x: complex) -> complex: ... def __rsub__(self, __x: complex) -> complex: ... def __rmul__(self, __x: complex) -> complex: ... def __rpow__(self, __x: complex, __mod: None = ...) -> complex: ... def __rtruediv__(self, __x: complex) -> complex: ... + def __eq__(self, __x: object) -> bool: ... + def __ne__(self, __x: object) -> bool: ... def __neg__(self) -> complex: ... def __pos__(self) -> complex: ... def __abs__(self) -> float: ... From 321ac8350c1d6025d0c3cc474ea76cdf065ebb7f Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 9 Jan 2022 19:08:24 +0000 Subject: [PATCH 8/8] Update stdlib/concurrent/futures/process.pyi --- stdlib/concurrent/futures/process.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index 31df900b8126..900c46e19f1c 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -36,6 +36,7 @@ class _ExceptionWithTraceback: exc: BaseException tb: TracebackType def __init__(self, exc: BaseException, tb: TracebackType) -> None: ... + def __reduce__(self) -> str | tuple[Any, ...]: ... def _rebuild_exc(exc: Exception, tb: str) -> Exception: ...