From e2a409291daee1dc481be30b1e53216bac9d6fab Mon Sep 17 00:00:00 2001 From: Shantanu Date: Fri, 6 Mar 2020 02:23:03 -0800 Subject: [PATCH] asyncore: various fixes (#3820) --- stdlib/2and3/asyncore.pyi | 30 ++++++++++++------------ tests/stubtest_whitelists/py3_common.txt | 14 ----------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/stdlib/2and3/asyncore.pyi b/stdlib/2and3/asyncore.pyi index b3801ff32..b93bd6c58 100644 --- a/stdlib/2and3/asyncore.pyi +++ b/stdlib/2and3/asyncore.pyi @@ -23,12 +23,12 @@ class ExitNow(Exception): ... def read(obj: Any) -> None: ... def write(obj: Any) -> None: ... def readwrite(obj: Any, flags: int) -> None: ... -def poll(timeout: float = ..., map: _maptype = ...) -> None: ... -def poll2(timeout: float = ..., map: _maptype = ...) -> None: ... +def poll(timeout: float = ..., map: Optional[_maptype] = ...) -> None: ... +def poll2(timeout: float = ..., map: Optional[_maptype] = ...) -> None: ... poll3 = poll2 -def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: Optional[int] = ...) -> None: ... +def loop(timeout: float = ..., use_poll: bool = ..., map: Optional[_maptype] = ..., count: Optional[int] = ...) -> None: ... # Not really subclass of socket.socket; it's only delegation. @@ -43,16 +43,16 @@ class dispatcher: ignore_log_types: frozenset[str] socket: Optional[SocketType] - def __init__(self, sock: Optional[SocketType] = ..., map: _maptype = ...) -> None: ... - def add_channel(self, map: _maptype = ...) -> None: ... - def del_channel(self, map: _maptype = ...) -> None: ... - def create_socket(self, family: int, type: int) -> None: ... - def set_socket(self, sock: SocketType, map: _maptype = ...) -> None: ... + def __init__(self, sock: Optional[SocketType] = ..., map: Optional[_maptype] = ...) -> None: ... + def add_channel(self, map: Optional[_maptype] = ...) -> None: ... + def del_channel(self, map: Optional[_maptype] = ...) -> None: ... + def create_socket(self, family: int = ..., type: int = ...) -> None: ... + def set_socket(self, sock: SocketType, map: Optional[_maptype] = ...) -> None: ... def set_reuse_addr(self) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... - def listen(self, backlog: int) -> None: ... - def bind(self, address: Union[Tuple[Any, ...], str]) -> None: ... + def listen(self, num: int) -> None: ... + def bind(self, addr: Union[Tuple[Any, ...], str]) -> None: ... def connect(self, address: Union[Tuple[Any, ...], str]) -> None: ... def accept(self) -> Optional[Tuple[SocketType, Any]]: ... def send(self, data: bytes) -> int: ... @@ -87,7 +87,7 @@ class dispatcher: def getsockname(self) -> Any: ... @overload - def getsockopt(self, level: int, optname: int) -> int: ... + def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ... @overload def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... @@ -112,14 +112,14 @@ class dispatcher: def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): - def __init__(self, sock: SocketType = ..., map: _maptype = ...) -> None: ... + def __init__(self, sock: SocketType = ..., map: Optional[_maptype] = ...) -> None: ... def initiate_send(self) -> None: ... def handle_write(self) -> None: ... # incompatible signature: # def send(self, data: bytes) -> Optional[int]: ... def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ... -def close_all(map: _maptype = ..., ignore_all: bool = ...) -> None: ... +def close_all(map: Optional[_maptype] = ..., ignore_all: bool = ...) -> None: ... # if os.name == 'posix': # import fcntl @@ -131,7 +131,7 @@ class file_wrapper: def send(self, data: bytes, flags: int = ...) -> int: ... @overload - def getsockopt(self, level: int, optname: int) -> int: ... + def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ... @overload def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... @@ -142,5 +142,5 @@ class file_wrapper: def fileno(self) -> int: ... class file_dispatcher(dispatcher): - def __init__(self, fd: FileDescriptorLike, map: _maptype = ...) -> None: ... + def __init__(self, fd: FileDescriptorLike, map: Optional[_maptype] = ...) -> None: ... def set_file(self, fd: int) -> None: ... diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 3e853779a..69ce1dd71 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -68,20 +68,6 @@ asyncio.unix_events._UnixSelectorEventLoop.create_unix_server asyncio.windows_events asyncio.windows_utils asyncio.wrap_future -asyncore.close_all -asyncore.dispatcher.__init__ -asyncore.dispatcher.add_channel -asyncore.dispatcher.bind -asyncore.dispatcher.create_socket -asyncore.dispatcher.del_channel -asyncore.dispatcher.listen -asyncore.dispatcher.set_socket -asyncore.dispatcher_with_send.__init__ -asyncore.file_dispatcher.__init__ -asyncore.file_wrapper.getsockopt -asyncore.loop -asyncore.poll -asyncore.poll2 base64.b32decode base64.b64decode base64.b64encode