From d7dd9fb832c206d9caaf8813ff472ddf437cac6d Mon Sep 17 00:00:00 2001 From: Yusuke Miyazaki Date: Tue, 9 May 2017 08:28:04 +0900 Subject: [PATCH] Update stub for ipaddress (#1251) --- stdlib/3.3/ipaddress.pyi | 141 ++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/stdlib/3.3/ipaddress.pyi b/stdlib/3.3/ipaddress.pyi index 69c2454fd..05f1b3e2c 100644 --- a/stdlib/3.3/ipaddress.pyi +++ b/stdlib/3.3/ipaddress.pyi @@ -2,23 +2,16 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any +from typing import Any, Iterator, Optional, Tuple, TypeVar, Union -IPV4LENGTH = ... # type: Any -IPV6LENGTH = ... # type: Any +_address = Union[bytes, int, str] + +IPV4LENGTH = ... # type: int +IPV6LENGTH = ... # type: int class AddressValueError(ValueError): ... class NetmaskValueError(ValueError): ... -def ip_address(address): ... -def ip_network(address, strict=...): ... -def ip_interface(address): ... -def v4_int_to_packed(address): ... -def v6_int_to_packed(address): ... -def summarize_address_range(first, last): ... -def collapse_addresses(addresses): ... -def get_mixed_type_key(obj): ... - class _TotalOrderingMixin: def __eq__(self, other): ... def __ne__(self, other): ... @@ -95,46 +88,46 @@ class _BaseV4: def version(self): ... class IPv4Address(_BaseV4, _BaseAddress): - def __init__(self, address) -> None: ... + def __init__(self, address: _address) -> None: ... @property - def packed(self): ... + def packed(self) -> bytes: ... @property - def is_reserved(self): ... + def is_reserved(self) -> bool: ... @property - def is_private(self): ... + def is_private(self) -> bool: ... @property - def is_multicast(self): ... + def is_multicast(self) -> bool: ... @property - def is_unspecified(self): ... + def is_unspecified(self) -> bool: ... @property - def is_loopback(self): ... + def is_loopback(self) -> bool: ... @property - def is_link_local(self): ... + def is_link_local(self) -> bool: ... class IPv4Interface(IPv4Address): - network = ... # type: Any - netmask = ... # type: Any - hostmask = ... # type: Any - def __init__(self, address) -> None: ... - def __eq__(self, other): ... - def __lt__(self, other): ... - def __hash__(self): ... + network = ... # type: IPv4Network + netmask = ... # type: IPv4Address + hostmask = ... # type: IPv4Address + def __init__(self, address: _address) -> None: ... + def __eq__(self, other: Any) -> bool: ... + def __lt__(self, other: Any) -> bool: ... + def __hash__(self) -> int: ... @property - def ip(self): ... + def ip(self) -> IPv4Address: ... @property - def with_prefixlen(self): ... + def with_prefixlen(self) -> str: ... @property - def with_netmask(self): ... + def with_netmask(self) -> str: ... @property - def with_hostmask(self): ... + def with_hostmask(self) -> str: ... class IPv4Network(_BaseV4, _BaseNetwork): - network_address = ... # type: Any - netmask = ... # type: Any - hosts = ... # type: Any - def __init__(self, address, strict=...) -> None: ... + network_address = ... # type: IPv4Address + netmask = ... # type: IPv4Address + hosts = ... # type: Iterator[IPv4Address] + def __init__(self, address: _address, strict: bool = ...) -> None: ... @property - def is_global(self): ... + def is_global(self) -> bool: ... class _BaseV6: def __init__(self, address) -> None: ... @@ -144,57 +137,71 @@ class _BaseV6: def version(self): ... class IPv6Address(_BaseV6, _BaseAddress): - def __init__(self, address) -> None: ... + def __init__(self, address: _address) -> None: ... @property - def packed(self): ... + def packed(self) -> bytes: ... @property - def is_multicast(self): ... + def is_multicast(self) -> bool: ... @property - def is_reserved(self): ... + def is_reserved(self) -> bool: ... @property - def is_link_local(self): ... + def is_link_local(self) -> bool: ... @property - def is_site_local(self): ... + def is_site_local(self) -> bool: ... @property - def is_private(self): ... + def is_private(self) -> bool: ... @property - def is_global(self): ... + def is_global(self) -> bool: ... @property - def is_unspecified(self): ... + def is_unspecified(self) -> bool: ... @property - def is_loopback(self): ... + def is_loopback(self) -> bool: ... @property - def ipv4_mapped(self): ... + def ipv4_mapped(self) -> Optional[IPv4Address]: ... @property - def teredo(self): ... + def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ... @property - def sixtofour(self): ... + def sixtofour(self) -> Optional[IPv4Address]: ... class IPv6Interface(IPv6Address): - network = ... # type: Any - netmask = ... # type: Any - hostmask = ... # type: Any - def __init__(self, address) -> None: ... - def __eq__(self, other): ... - def __lt__(self, other): ... - def __hash__(self): ... + network = ... # type: IPv6Network + netmask = ... # type: IPv6Address + hostmask = ... # type: IPv6Address + def __init__(self, address: _address) -> None: ... + def __eq__(self, other: Any) -> bool: ... + def __lt__(self, other: Any) -> bool: ... + def __hash__(self) -> int: ... @property - def ip(self): ... + def ip(self) -> IPv6Address: ... @property - def with_prefixlen(self): ... + def with_prefixlen(self) -> str: ... @property - def with_netmask(self): ... + def with_netmask(self) -> str: ... @property - def with_hostmask(self): ... + def with_hostmask(self) -> str: ... @property - def is_unspecified(self): ... + def is_unspecified(self) -> bool: ... @property - def is_loopback(self): ... + def is_loopback(self) -> bool: ... class IPv6Network(_BaseV6, _BaseNetwork): - network_address = ... # type: Any - netmask = ... # type: Any - def __init__(self, address, strict=...) -> None: ... - def hosts(self): ... + network_address = ... # type: IPv6Address + netmask = ... # type: IPv6Address + def __init__(self, address: _address, strict: bool = ...) -> None: ... + def hosts(self) -> Iterator[IPv6Address]: ... @property - def is_site_local(self): ... + def is_site_local(self) -> bool: ... + +_ip_address = Union[IPv4Address, IPv6Address] +_ip_network = Union[IPv4Network, IPv6Network] +_ip_interface = Union[IPv4Interface, IPv6Interface] +_AnyIPAddress = TypeVar("_AnyIPAddress", IPv4Address, IPv6Address) + +def ip_address(address: _address) -> _ip_address: ... +def ip_network(address: _address, strict: bool = ...) -> _ip_network: ... +def ip_interface(address: _address) -> _ip_interface: ... +def v4_int_to_packed(address: int) -> bytes: ... +def v6_int_to_packed(address: int) -> bytes: ... +def summarize_address_range(first: _AnyIPAddress, _AnyIPAddress) -> Iterator[_AnyIPAddress]: ... +def collapse_addresses(addresses: Iterator[_AnyIPAddress]) -> Iterator[_AnyIPAddress]: ... +def get_mixed_type_key(obj): ...