Skip to content

Commit 1a4631f

Browse files
authored
Remove fake base class ipaddress._BaseInterface (#12949)
Also make hostmask a property to improve stubtest
1 parent 9c8bc64 commit 1a4631f

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined
5959
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
6060
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
6161
importlib.machinery.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
62-
ipaddress.IPv4Interface.hostmask
63-
ipaddress.IPv6Interface.hostmask
6462
ipaddress._BaseAddress.is_global
6563
ipaddress._BaseAddress.is_link_local
6664
ipaddress._BaseAddress.is_loopback

stdlib/ipaddress.pyi

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,6 @@ class _BaseNetwork(_IPAddressBase, Generic[_A]):
128128
@property
129129
def hostmask(self) -> _A: ...
130130

131-
class _BaseInterface(_BaseAddress, Generic[_A, _N]):
132-
hostmask: _A
133-
netmask: _A
134-
network: _N
135-
@property
136-
def ip(self) -> _A: ...
137-
@property
138-
def with_hostmask(self) -> str: ...
139-
@property
140-
def with_netmask(self) -> str: ...
141-
@property
142-
def with_prefixlen(self) -> str: ...
143-
144131
class _BaseV4:
145132
@property
146133
def version(self) -> Literal[4]: ...
@@ -154,9 +141,21 @@ class IPv4Address(_BaseV4, _BaseAddress):
154141

155142
class IPv4Network(_BaseV4, _BaseNetwork[IPv4Address]): ...
156143

157-
class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]):
144+
class IPv4Interface(IPv4Address):
145+
netmask: IPv4Address
146+
network: IPv4Network
158147
def __eq__(self, other: object) -> bool: ...
159148
def __hash__(self) -> int: ...
149+
@property
150+
def hostmask(self) -> IPv4Address: ...
151+
@property
152+
def ip(self) -> IPv4Address: ...
153+
@property
154+
def with_hostmask(self) -> str: ...
155+
@property
156+
def with_netmask(self) -> str: ...
157+
@property
158+
def with_prefixlen(self) -> str: ...
160159

161160
class _BaseV6:
162161
@property
@@ -184,9 +183,21 @@ class IPv6Network(_BaseV6, _BaseNetwork[IPv6Address]):
184183
@property
185184
def is_site_local(self) -> bool: ...
186185

187-
class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]):
186+
class IPv6Interface(IPv6Address):
187+
netmask: IPv6Address
188+
network: IPv6Network
188189
def __eq__(self, other: object) -> bool: ...
189190
def __hash__(self) -> int: ...
191+
@property
192+
def hostmask(self) -> IPv6Address: ...
193+
@property
194+
def ip(self) -> IPv6Address: ...
195+
@property
196+
def with_hostmask(self) -> str: ...
197+
@property
198+
def with_netmask(self) -> str: ...
199+
@property
200+
def with_prefixlen(self) -> str: ...
190201

191202
def v4_int_to_packed(address: int) -> bytes: ...
192203
def v6_int_to_packed(address: int) -> bytes: ...

0 commit comments

Comments
 (0)