From 6f5dfcd05e6c39e568ac2ffca83de191828cbb78 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 17 Feb 2022 00:08:42 +0000 Subject: [PATCH] Improve `ipaddress` dunders --- stdlib/ipaddress.pyi | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index 373d7cffe6a9..acd00b223351 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -18,12 +18,6 @@ def ip_network(address: _RawIPAddress | _RawNetworkPart, strict: bool = ...) -> def ip_interface(address: _RawIPAddress | _RawNetworkPart) -> IPv4Interface | IPv6Interface: ... class _IPAddressBase: - def __eq__(self, __other: object) -> bool: ... - def __ge__(self: Self, __other: Self) -> bool: ... - def __gt__(self: Self, __other: Self) -> bool: ... - def __le__(self: Self, __other: Self) -> bool: ... - def __lt__(self: Self, __other: Self) -> bool: ... - def __ne__(self, __other: object) -> bool: ... @property def compressed(self) -> str: ... @property @@ -39,6 +33,18 @@ class _BaseAddress(_IPAddressBase, SupportsInt): def __hash__(self) -> int: ... def __int__(self) -> int: ... def __sub__(self: Self, other: int) -> Self: ... + def __format__(self, fmt: str) -> str: ... + def __eq__(self, other: object) -> bool: ... + def __lt__(self: Self, other: Self) -> bool: ... + if sys.version_info >= (3, 11): + def __ge__(self: Self, other: Self) -> bool: ... + def __gt__(self: Self, other: Self) -> bool: ... + def __le__(self: Self, other: Self) -> bool: ... + else: + def __ge__(self: Self, other: Self, NotImplemented: Any = ...) -> bool: ... + def __gt__(self: Self, other: Self, NotImplemented: Any = ...) -> bool: ... + def __le__(self: Self, other: Self, NotImplemented: Any = ...) -> bool: ... + @property def is_global(self) -> bool: ... @property @@ -65,6 +71,17 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def __contains__(self, other: Any) -> bool: ... def __getitem__(self, n: int) -> _A: ... def __iter__(self) -> Iterator[_A]: ... + def __eq__(self, other: object) -> bool: ... + def __lt__(self: Self, other: Self) -> bool: ... + if sys.version_info >= (3, 11): + def __ge__(self: Self, other: Self) -> bool: ... + def __gt__(self: Self, other: Self) -> bool: ... + def __le__(self: Self, other: Self) -> bool: ... + else: + def __ge__(self: Self, other: Self, NotImplemented: Any = ...) -> bool: ... + def __gt__(self: Self, other: Self, NotImplemented: Any = ...) -> bool: ... + def __le__(self: Self, other: Self, NotImplemented: Any = ...) -> bool: ... + def address_exclude(self: Self, other: Self) -> Iterator[Self]: ... @property def broadcast_address(self) -> _A: ...