From ad89dee03be85f575a5c0384f238b757ad2b624e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Fri, 10 Jul 2020 11:46:28 +0300 Subject: [PATCH] Fixed return type of getaddrinfo() everywhere (#4304) --- stdlib/2and3/socket.pyi | 4 +--- stdlib/3/asyncio/base_events.pyi | 6 ++---- stdlib/3/asyncio/events.pyi | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/stdlib/2and3/socket.pyi b/stdlib/2and3/socket.pyi index 6cfb40d0a..c48d433b1 100644 --- a/stdlib/2and3/socket.pyi +++ b/stdlib/2and3/socket.pyi @@ -755,8 +755,6 @@ if sys.platform == "win32" and sys.version_info >= (3, 3): def fromshare(info: bytes) -> socket: ... # the 5th tuple item is an address -# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers -# https://github.com/python/mypy/issues/2509 if sys.version_info >= (3,): def getaddrinfo( host: Optional[Union[bytearray, bytes, Text]], @@ -765,7 +763,7 @@ if sys.version_info >= (3,): type: int = ..., proto: int = ..., flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]: ... + ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... else: def getaddrinfo( diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index 56010b2b5..7d35d9a70 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -7,7 +7,7 @@ from asyncio.futures import Future from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport -from socket import _Address, _RetAddress, socket +from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload from typing_extensions import Literal @@ -75,8 +75,6 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): ) -> Future[_T]: ... def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. - # TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers - # https://github.com/python/mypy/issues/2509 async def getaddrinfo( self, host: Optional[str], @@ -86,7 +84,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): type: int = ..., proto: int = ..., flags: int = ..., - ) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: ... + ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... async def getnameinfo( self, sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int = ... ) -> Tuple[str, str]: ... diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index b044bd095..c2226a0a3 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -7,7 +7,7 @@ from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport from asyncio.unix_events import AbstractChildWatcher -from socket import _Address, _RetAddress, socket +from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload if sys.version_info >= (3, 7): @@ -121,8 +121,6 @@ class AbstractEventLoop(metaclass=ABCMeta): def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. @abstractmethod - # TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers - # https://github.com/python/mypy/issues/2509 async def getaddrinfo( self, host: Optional[str], @@ -132,7 +130,7 @@ class AbstractEventLoop(metaclass=ABCMeta): type: int = ..., proto: int = ..., flags: int = ..., - ) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: ... + ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... @abstractmethod async def getnameinfo( self, sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int = ...