Skip to content

Commit

Permalink
Remove fake base class ipaddress._BaseInterface (#12949)
Browse files Browse the repository at this point in the history
Also make hostmask a property to improve stubtest
  • Loading branch information
tungol authored Nov 4, 2024
1 parent 9c8bc64 commit 1a4631f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
2 changes: 0 additions & 2 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 26 additions & 15 deletions stdlib/ipaddress.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
Expand All @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down

0 comments on commit 1a4631f

Please sign in to comment.