2 from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, TypeVar, overload
4 # Undocumented length constants
8 _A = TypeVar("_A", IPv4Address, IPv6Address)
9 _N = TypeVar("_N", IPv4Network, IPv6Network)
12 def ip_address(address: object) -> Any: ... # morally IPv4Address | IPv6Address
13 def ip_network(address: object, strict: bool = ...) -> Any: ... # morally IPv4Network | IPv6Network
14 def ip_interface(address: object) -> Any: ... # morally IPv4Interface | IPv6Interface
17 def __eq__(self, other: Any) -> bool: ...
18 def __ge__(self: _T, other: _T) -> bool: ...
19 def __gt__(self: _T, other: _T) -> bool: ...
20 def __le__(self: _T, other: _T) -> bool: ...
21 def __lt__(self: _T, other: _T) -> bool: ...
22 def __ne__(self, other: Any) -> bool: ...
24 def compressed(self) -> str: ...
26 def exploded(self) -> str: ...
28 def reverse_pointer(self) -> str: ...
30 def version(self) -> int: ...
32 class _BaseAddress(_IPAddressBase, SupportsInt):
33 def __init__(self, address: object) -> None: ...
34 def __add__(self: _T, other: int) -> _T: ...
35 def __hash__(self) -> int: ...
36 def __int__(self) -> int: ...
37 def __sub__(self: _T, other: int) -> _T: ...
39 def is_global(self) -> bool: ...
41 def is_link_local(self) -> bool: ...
43 def is_loopback(self) -> bool: ...
45 def is_multicast(self) -> bool: ...
47 def is_private(self) -> bool: ...
49 def is_reserved(self) -> bool: ...
51 def is_unspecified(self) -> bool: ...
53 def max_prefixlen(self) -> int: ...
55 def packed(self) -> bytes: ...
57 class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
60 def __init__(self, address: object, strict: bool = ...) -> None: ...
61 def __contains__(self, other: Any) -> bool: ...
62 def __getitem__(self, n: int) -> _A: ...
63 def __iter__(self) -> Iterator[_A]: ...
64 def address_exclude(self: _T, other: _T) -> Iterator[_T]: ...
66 def broadcast_address(self) -> _A: ...
67 def compare_networks(self: _T, other: _T) -> int: ...
68 def hosts(self) -> Iterator[_A]: ...
70 def is_global(self) -> bool: ...
72 def is_link_local(self) -> bool: ...
74 def is_loopback(self) -> bool: ...
76 def is_multicast(self) -> bool: ...
78 def is_private(self) -> bool: ...
80 def is_reserved(self) -> bool: ...
82 def is_unspecified(self) -> bool: ...
84 def max_prefixlen(self) -> int: ...
86 def num_addresses(self) -> int: ...
87 def overlaps(self, other: _BaseNetwork[_A]) -> bool: ...
89 def prefixlen(self) -> int: ...
90 if sys.version_info >= (3, 7):
91 def subnet_of(self: _T, other: _T) -> bool: ...
92 def supernet_of(self: _T, other: _T) -> bool: ...
93 def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Iterator[_T]: ...
94 def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> _T: ...
96 def with_hostmask(self) -> str: ...
98 def with_netmask(self) -> str: ...
100 def with_prefixlen(self) -> str: ...
102 def hostmask(self) -> _A: ...
104 class _BaseInterface(_BaseAddress, Generic[_A, _N]):
109 def ip(self) -> _A: ...
111 def with_hostmask(self) -> str: ...
113 def with_netmask(self) -> str: ...
115 def with_prefixlen(self) -> str: ...
117 class IPv4Address(_BaseAddress): ...
118 class IPv4Network(_BaseNetwork[IPv4Address]): ...
119 class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ...
121 class IPv6Address(_BaseAddress):
123 def ipv4_mapped(self) -> IPv4Address | None: ...
125 def is_site_local(self) -> bool: ...
127 def sixtofour(self) -> IPv4Address | None: ...
129 def teredo(self) -> tuple[IPv4Address, IPv4Address] | None: ...
131 class IPv6Network(_BaseNetwork[IPv6Address]):
133 def is_site_local(self) -> bool: ...
135 class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): ...
137 def v4_int_to_packed(address: int) -> bytes: ...
138 def v6_int_to_packed(address: int) -> bytes: ...
140 def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[IPv4Network]: ...
142 def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ...
143 def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ...
145 def get_mixed_type_key(obj: _A) -> tuple[int, _A]: ...
147 def get_mixed_type_key(obj: IPv4Network) -> tuple[int, IPv4Address, IPv4Address]: ...
149 def get_mixed_type_key(obj: IPv6Network) -> tuple[int, IPv6Address, IPv6Address]: ...
151 class AddressValueError(ValueError): ...
152 class NetmaskValueError(ValueError): ...