mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-30 14:45:23 +08:00
Add new methods to socket stubs. (#1638)
* Add new methods to socket stubs. Also fix a couple of invalid types in recv*_into() socket methods. * Add double-underscores to parameters for position-only arguments
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
# see: http://nullege.com/codes/search/socket
|
||||
# adapted for Python 2.7 by Michal Pokorny
|
||||
import sys
|
||||
from typing import Any, Tuple, List, Optional, Union, overload, TypeVar
|
||||
from typing import Any, Iterable, Tuple, List, Optional, Union, overload, TypeVar
|
||||
|
||||
|
||||
# ----- variables and constants -----
|
||||
@@ -498,6 +498,7 @@ class timeout(error):
|
||||
|
||||
# TODO AF_PACKET and AF_BLUETOOTH address objects
|
||||
|
||||
_CMSG = Tuple[int, int, bytes]
|
||||
_SelfT = TypeVar('_SelfT', bound=socket)
|
||||
|
||||
# ----- classes -----
|
||||
@@ -549,9 +550,9 @@ class socket:
|
||||
|
||||
# return type is an address
|
||||
def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ...
|
||||
def recvfrom_into(self, buffer: bytes, nbytes: int,
|
||||
def recvfrom_into(self, buffer: bytearray, nbytes: int,
|
||||
flags: int = ...) -> Any: ...
|
||||
def recv_into(self, buffer: bytes, nbytes: int,
|
||||
def recv_into(self, buffer: bytearray, nbytes: int,
|
||||
flags: int = ...) -> Any: ...
|
||||
def send(self, data: bytes, flags: int = ...) -> int: ...
|
||||
def sendall(self, data: bytes, flags: int =...) -> None:
|
||||
@@ -565,6 +566,14 @@ class socket:
|
||||
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
|
||||
def shutdown(self, how: int) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
def recvmsg(self, __bufsize: int, __ancbufsize: int = ...,
|
||||
__flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ...
|
||||
def recvmsg_into(self, __buffers: Iterable[bytearray], __ancbufsize: int = ...,
|
||||
__flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ...
|
||||
def sendmsg(self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ...,
|
||||
__flags: int = ..., __address: Any = ...) -> int: ...
|
||||
|
||||
|
||||
# ----- functions -----
|
||||
def create_connection(address: Tuple[str, int],
|
||||
@@ -603,3 +612,11 @@ def inet_pton(address_family: int, ip_string: str) -> bytes: ...
|
||||
def inet_ntop(address_family: int, packed_ip: bytes) -> str: ...
|
||||
def getdefaulttimeout() -> Optional[float]: ...
|
||||
def setdefaulttimeout(timeout: Optional[float]) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
def CMSG_LEN(length: int) -> int: ...
|
||||
def CMSG_SPACE(length: int) -> int: ...
|
||||
def sethostname(name: str) -> None: ...
|
||||
def if_nameindex() -> List[Tuple[int, str]]: ...
|
||||
def if_nametoindex(name: str) -> int: ...
|
||||
def if_indextoname(index: int) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user