From 1a4631f0d235ad1bb2bc676b328bef5110167399 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Mon, 4 Nov 2024 06:59:21 -0800 Subject: [PATCH] Remove fake base class ipaddress._BaseInterface (#12949) Also make hostmask a property to improve stubtest --- stdlib/@tests/stubtest_allowlists/common.txt | 2 - stdlib/ipaddress.pyi | 41 +++++++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index f3d4d8e5cd8c..fb4ac3c9e4af 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -59,8 +59,6 @@ importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist. importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist. importlib.machinery.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature -ipaddress.IPv4Interface.hostmask -ipaddress.IPv6Interface.hostmask ipaddress._BaseAddress.is_global ipaddress._BaseAddress.is_link_local ipaddress._BaseAddress.is_loopback diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index fa2faf8e6c13..fce233e84555 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -128,19 +128,6 @@ class _BaseNetwork(_IPAddressBase, Generic[_A]): @property def hostmask(self) -> _A: ... -class _BaseInterface(_BaseAddress, Generic[_A, _N]): - hostmask: _A - netmask: _A - network: _N - @property - def ip(self) -> _A: ... - @property - def with_hostmask(self) -> str: ... - @property - def with_netmask(self) -> str: ... - @property - def with_prefixlen(self) -> str: ... - class _BaseV4: @property def version(self) -> Literal[4]: ... @@ -154,9 +141,21 @@ class IPv4Address(_BaseV4, _BaseAddress): class IPv4Network(_BaseV4, _BaseNetwork[IPv4Address]): ... -class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): +class IPv4Interface(IPv4Address): + netmask: IPv4Address + network: IPv4Network def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... + @property + def hostmask(self) -> IPv4Address: ... + @property + def ip(self) -> IPv4Address: ... + @property + def with_hostmask(self) -> str: ... + @property + def with_netmask(self) -> str: ... + @property + def with_prefixlen(self) -> str: ... class _BaseV6: @property @@ -184,9 +183,21 @@ class IPv6Network(_BaseV6, _BaseNetwork[IPv6Address]): @property def is_site_local(self) -> bool: ... -class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): +class IPv6Interface(IPv6Address): + netmask: IPv6Address + network: IPv6Network def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... + @property + def hostmask(self) -> IPv6Address: ... + @property + def ip(self) -> IPv6Address: ... + @property + def with_hostmask(self) -> str: ... + @property + def with_netmask(self) -> str: ... + @property + def with_prefixlen(self) -> str: ... def v4_int_to_packed(address: int) -> bytes: ... def v6_int_to_packed(address: int) -> bytes: ...