mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 16:14:24 +08:00
Improve ipaddress module (#7129)
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
# Undocumented length constants
|
||||
IPV4LENGTH: int
|
||||
IPV6LENGTH: int
|
||||
IPV4LENGTH: Literal[32]
|
||||
IPV6LENGTH: Literal[128]
|
||||
|
||||
_A = TypeVar("_A", IPv4Address, IPv6Address)
|
||||
_N = TypeVar("_N", IPv4Network, IPv6Network)
|
||||
|
||||
def ip_address(address: object) -> IPv4Address | IPv6Address: ...
|
||||
def ip_network(address: object, strict: bool = ...) -> IPv4Network | IPv6Network: ...
|
||||
def ip_interface(address: object) -> IPv4Interface | IPv6Interface: ...
|
||||
_RawIPAddress = int | str | bytes | IPv4Address | IPv6Address
|
||||
_RawNetworkPart = IPv4Network | IPv6Network | IPv4Interface | IPv6Interface
|
||||
|
||||
def ip_address(address: _RawIPAddress) -> IPv4Address | IPv6Address: ...
|
||||
def ip_network(address: _RawIPAddress | _RawNetworkPart, strict: bool = ...) -> IPv4Network | IPv6Network: ...
|
||||
def ip_interface(address: _RawIPAddress | _RawNetworkPart) -> IPv4Interface | IPv6Interface: ...
|
||||
|
||||
class _IPAddressBase:
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
@@ -115,11 +119,23 @@ class _BaseInterface(_BaseAddress, Generic[_A, _N]):
|
||||
@property
|
||||
def with_prefixlen(self) -> str: ...
|
||||
|
||||
class IPv4Address(_BaseAddress): ...
|
||||
class IPv4Network(_BaseNetwork[IPv4Address]): ...
|
||||
class _BaseV4:
|
||||
@property
|
||||
def version(self) -> Literal[4]: ...
|
||||
@property
|
||||
def max_prefixlen(self) -> Literal[32]: ...
|
||||
|
||||
class IPv4Address(_BaseV4, _BaseAddress): ...
|
||||
class IPv4Network(_BaseV4, _BaseNetwork[IPv4Address]): ...
|
||||
class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ...
|
||||
|
||||
class IPv6Address(_BaseAddress):
|
||||
class _BaseV6:
|
||||
@property
|
||||
def version(self) -> Literal[6]: ...
|
||||
@property
|
||||
def max_prefixlen(self) -> Literal[128]: ...
|
||||
|
||||
class IPv6Address(_BaseV6, _BaseAddress):
|
||||
@property
|
||||
def ipv4_mapped(self) -> IPv4Address | None: ...
|
||||
@property
|
||||
@@ -132,7 +148,7 @@ class IPv6Address(_BaseAddress):
|
||||
@property
|
||||
def scope_id(self) -> str | None: ...
|
||||
|
||||
class IPv6Network(_BaseNetwork[IPv6Address]):
|
||||
class IPv6Network(_BaseV6, _BaseNetwork[IPv6Address]):
|
||||
@property
|
||||
def is_site_local(self) -> bool: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user