mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Switch to PEP-604 syntax in python2 stubs (#5915)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from typing import Any, BinaryIO, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload
|
||||
from typing import Any, BinaryIO, Iterable, List, Text, Tuple, TypeVar, Union, overload
|
||||
|
||||
# ----- Constants -----
|
||||
# Some socket families are listed in the "Socket families" section of the docs,
|
||||
@@ -389,10 +389,10 @@ class socket:
|
||||
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
|
||||
# --- methods ---
|
||||
def accept(self) -> Tuple[socket, _RetAddress]: ...
|
||||
def bind(self, address: Union[_Address, bytes]) -> None: ...
|
||||
def bind(self, address: _Address | bytes) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def connect(self, address: Union[_Address, bytes]) -> None: ...
|
||||
def connect_ex(self, address: Union[_Address, bytes]) -> int: ...
|
||||
def connect(self, address: _Address | bytes) -> None: ...
|
||||
def connect_ex(self, address: _Address | bytes) -> int: ...
|
||||
def detach(self) -> int: ...
|
||||
def dup(self) -> socket: ...
|
||||
def fileno(self) -> int: ...
|
||||
@@ -402,9 +402,9 @@ class socket:
|
||||
def getsockopt(self, level: int, optname: int) -> int: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||
def gettimeout(self) -> Optional[float]: ...
|
||||
def gettimeout(self) -> float | None: ...
|
||||
if sys.platform == "win32":
|
||||
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ...
|
||||
def ioctl(self, control: int, option: int | Tuple[int, int, int]) -> None: ...
|
||||
def listen(self, __backlog: int) -> None: ...
|
||||
# Note that the makefile's documented windows-specific behavior is not represented
|
||||
def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
|
||||
@@ -419,8 +419,8 @@ class socket:
|
||||
@overload
|
||||
def sendto(self, data: bytes, flags: int, address: _Address) -> int: ...
|
||||
def setblocking(self, flag: bool) -> None: ...
|
||||
def settimeout(self, value: Optional[float]) -> None: ...
|
||||
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
|
||||
def settimeout(self, value: float | None) -> None: ...
|
||||
def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ...
|
||||
if sys.platform == "win32":
|
||||
def share(self, process_id: int) -> bytes: ...
|
||||
def shutdown(self, how: int) -> None: ...
|
||||
@@ -428,16 +428,16 @@ class socket:
|
||||
# ----- Functions -----
|
||||
|
||||
def create_connection(
|
||||
address: Tuple[Optional[str], int],
|
||||
timeout: Optional[float] = ...,
|
||||
source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ...,
|
||||
address: Tuple[str | None, int],
|
||||
timeout: float | None = ...,
|
||||
source_address: Tuple[bytearray | bytes | Text, int] | None = ...,
|
||||
) -> socket: ...
|
||||
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...
|
||||
|
||||
# the 5th tuple item is an address
|
||||
def getaddrinfo(
|
||||
host: Optional[Union[bytearray, bytes, Text]],
|
||||
port: Union[str, int, None],
|
||||
host: bytearray | bytes | Text | None,
|
||||
port: str | int | None,
|
||||
family: int = ...,
|
||||
socktype: int = ...,
|
||||
proto: int = ...,
|
||||
@@ -448,7 +448,7 @@ def gethostbyname(hostname: str) -> str: ...
|
||||
def gethostbyname_ex(hostname: str) -> Tuple[str, List[str], List[str]]: ...
|
||||
def gethostname() -> str: ...
|
||||
def gethostbyaddr(ip_address: str) -> Tuple[str, List[str], List[str]]: ...
|
||||
def getnameinfo(sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int) -> Tuple[str, str]: ...
|
||||
def getnameinfo(sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int) -> Tuple[str, str]: ...
|
||||
def getprotobyname(protocolname: str) -> int: ...
|
||||
def getservbyname(servicename: str, protocolname: str = ...) -> int: ...
|
||||
def getservbyport(port: int, protocolname: str = ...) -> str: ...
|
||||
@@ -457,7 +457,7 @@ if sys.platform == "win32":
|
||||
def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ...
|
||||
|
||||
else:
|
||||
def socketpair(family: Optional[int] = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ...
|
||||
def socketpair(family: int | None = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ...
|
||||
|
||||
def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints
|
||||
def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints
|
||||
@@ -467,5 +467,5 @@ def inet_aton(ip_string: str) -> bytes: ... # ret val 4 bytes in length
|
||||
def inet_ntoa(packed_ip: bytes) -> str: ...
|
||||
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: ...
|
||||
def getdefaulttimeout() -> float | None: ...
|
||||
def setdefaulttimeout(timeout: float | None) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user