mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
ipaddress: return unions from ip_address, ip_network, ip_interface (#6400)
This commit is contained in:
@@ -9,9 +9,9 @@ _A = TypeVar("_A", IPv4Address, IPv6Address)
|
||||
_N = TypeVar("_N", IPv4Network, IPv6Network)
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def ip_address(address: object) -> Any: ... # morally IPv4Address | IPv6Address
|
||||
def ip_network(address: object, strict: bool = ...) -> Any: ... # morally IPv4Network | IPv6Network
|
||||
def ip_interface(address: object) -> Any: ... # morally IPv4Interface | IPv6Interface
|
||||
def ip_address(address: object) -> IPv4Address | IPv6Address: ...
|
||||
def ip_network(address: object, strict: bool = ...) -> IPv4Network | IPv6Network: ...
|
||||
def ip_interface(address: object) -> IPv4Interface | IPv6Interface: ...
|
||||
|
||||
class _IPAddressBase:
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
@@ -139,10 +139,16 @@ class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): ...
|
||||
|
||||
def v4_int_to_packed(address: int) -> bytes: ...
|
||||
def v6_int_to_packed(address: int) -> bytes: ...
|
||||
|
||||
# Third overload is technically incorrect, but convenient when first and last are return values of ip_address()
|
||||
@overload
|
||||
def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[IPv4Network]: ...
|
||||
@overload
|
||||
def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ...
|
||||
@overload
|
||||
def summarize_address_range(
|
||||
first: IPv4Address | IPv6Address, last: IPv4Address | IPv6Address
|
||||
) -> Iterator[IPv4Network] | Iterator[IPv6Network]: ...
|
||||
def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: _A) -> tuple[int, _A]: ...
|
||||
|
||||
Reference in New Issue
Block a user