mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
ssl, socket, array: Improve bytes handling (#8997)
This commit is contained in:
@@ -15,10 +15,10 @@ _CMSG: TypeAlias = tuple[int, int, bytes]
|
||||
_CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer]
|
||||
|
||||
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
|
||||
# AF_NETLINK, AF_TIPC) or strings (AF_UNIX).
|
||||
_Address: TypeAlias = tuple[Any, ...] | str
|
||||
# AF_NETLINK, AF_TIPC) or strings/buffers (AF_UNIX).
|
||||
# See getsockaddrarg() in socketmodule.c.
|
||||
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer
|
||||
_RetAddress: TypeAlias = Any
|
||||
# TODO Most methods allow bytes as address objects
|
||||
|
||||
# ----- Constants -----
|
||||
# Some socket families are listed in the "Socket families" section of the docs,
|
||||
@@ -584,10 +584,10 @@ class socket:
|
||||
@property
|
||||
def timeout(self) -> float | None: ...
|
||||
def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: _FD | None = ...) -> None: ...
|
||||
def bind(self, __address: _Address | bytes) -> None: ...
|
||||
def bind(self, __address: _Address) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def connect(self, __address: _Address | bytes) -> None: ...
|
||||
def connect_ex(self, __address: _Address | bytes) -> int: ...
|
||||
def connect(self, __address: _Address) -> None: ...
|
||||
def connect_ex(self, __address: _Address) -> int: ...
|
||||
def detach(self) -> int: ...
|
||||
def fileno(self) -> int: ...
|
||||
def getpeername(self) -> _RetAddress: ...
|
||||
@@ -634,7 +634,7 @@ class socket:
|
||||
def setblocking(self, __flag: bool) -> None: ...
|
||||
def settimeout(self, __value: float | None) -> None: ...
|
||||
@overload
|
||||
def setsockopt(self, __level: int, __optname: int, __value: int | bytes) -> None: ...
|
||||
def setsockopt(self, __level: int, __optname: int, __value: int | ReadableBuffer) -> None: ...
|
||||
@overload
|
||||
def setsockopt(self, __level: int, __optname: int, __value: None, __optlen: int) -> None: ...
|
||||
if sys.platform == "win32":
|
||||
@@ -671,9 +671,9 @@ def ntohs(__x: int) -> int: ... # param & ret val are 16-bit ints
|
||||
def htonl(__x: int) -> int: ... # param & ret val are 32-bit ints
|
||||
def htons(__x: int) -> int: ... # param & ret val are 16-bit ints
|
||||
def inet_aton(__ip_string: str) -> bytes: ... # ret val 4 bytes in length
|
||||
def inet_ntoa(__packed_ip: bytes) -> str: ...
|
||||
def inet_ntoa(__packed_ip: ReadableBuffer) -> str: ...
|
||||
def inet_pton(__address_family: int, __ip_string: str) -> bytes: ...
|
||||
def inet_ntop(__address_family: int, __packed_ip: bytes) -> str: ...
|
||||
def inet_ntop(__address_family: int, __packed_ip: ReadableBuffer) -> str: ...
|
||||
def getdefaulttimeout() -> float | None: ...
|
||||
def setdefaulttimeout(__timeout: float | None) -> None: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user