From d8aab520565f718b735f15a24855d431da986a0a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 14 Mar 2017 09:44:47 -0700 Subject: [PATCH 1/3] drop union return type from getaddrinfo --- stdlib/2/socket.pyi | 4 +++- stdlib/3.4/asyncio/events.pyi | 4 +++- stdlib/3/socket.pyi | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/stdlib/2/socket.pyi b/stdlib/2/socket.pyi index 83ac7493fcf9..b3942e8c8663 100644 --- a/stdlib/2/socket.pyi +++ b/stdlib/2/socket.pyi @@ -335,10 +335,12 @@ def create_connection(address: Tuple[str, int], source_address: Tuple[str, int] = ...) -> 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 def getaddrinfo( host: Optional[str], port: Union[str, int, None], family: int = ..., socktype: int = ..., proto: int = ..., - flags: int = ...) -> List[Tuple[int, int, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: + flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any]]]: ... def getfqdn(name: str = ...) -> str: ... diff --git a/stdlib/3.4/asyncio/events.pyi b/stdlib/3.4/asyncio/events.pyi index 7aaa331e2b49..87d2b7c30f54 100644 --- a/stdlib/3.4/asyncio/events.pyi +++ b/stdlib/3.4/asyncio/events.pyi @@ -93,8 +93,10 @@ class AbstractEventLoop(metaclass=ABCMeta): # Network I/O methods returning Futures. @abstractmethod @coroutine + # 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 def getaddrinfo(self, host: str, port: int, *, - family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]]: ... + family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any]]]]: ... @abstractmethod @coroutine def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ... diff --git a/stdlib/3/socket.pyi b/stdlib/3/socket.pyi index f6c7278986ba..6c6eb98dc0f2 100644 --- a/stdlib/3/socket.pyi +++ b/stdlib/3/socket.pyi @@ -331,10 +331,12 @@ def create_connection(address: Tuple[str, int], source_address: Tuple[str, int] = ...) -> 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 def getaddrinfo( host: Optional[str], port: Union[str, int, None], family: int = ..., socktype: int = ..., proto: int = ..., - flags: int = ...) -> List[Tuple[int, int, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: + flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any]]]: ... def getfqdn(name: str = ...) -> str: ... From 3b3990bd5c412421b4ee0692c68eabfb198f3c43 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 14 Mar 2017 10:49:37 -0700 Subject: [PATCH 2/3] use Tuple[Any, ...] sorry for not testing properly :( --- stdlib/2/socket.pyi | 4 ++-- stdlib/3.4/asyncio/events.pyi | 4 ++-- stdlib/3/socket.pyi | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/2/socket.pyi b/stdlib/2/socket.pyi index b3942e8c8663..a3072a41527d 100644 --- a/stdlib/2/socket.pyi +++ b/stdlib/2/socket.pyi @@ -335,12 +335,12 @@ def create_connection(address: Tuple[str, int], source_address: Tuple[str, int] = ...) -> 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 +# 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 def getaddrinfo( host: Optional[str], port: Union[str, int, None], family: int = ..., socktype: int = ..., proto: int = ..., - flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any]]]: + flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: ... def getfqdn(name: str = ...) -> str: ... diff --git a/stdlib/3.4/asyncio/events.pyi b/stdlib/3.4/asyncio/events.pyi index 87d2b7c30f54..40c293f4f703 100644 --- a/stdlib/3.4/asyncio/events.pyi +++ b/stdlib/3.4/asyncio/events.pyi @@ -93,10 +93,10 @@ class AbstractEventLoop(metaclass=ABCMeta): # Network I/O methods returning Futures. @abstractmethod @coroutine - # TODO the "Tuple[Any]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers + # 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 def getaddrinfo(self, host: str, port: int, *, - family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any]]]]: ... + family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ..]]]]: ... @abstractmethod @coroutine def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ... diff --git a/stdlib/3/socket.pyi b/stdlib/3/socket.pyi index 6c6eb98dc0f2..0675df1c1c91 100644 --- a/stdlib/3/socket.pyi +++ b/stdlib/3/socket.pyi @@ -331,12 +331,12 @@ def create_connection(address: Tuple[str, int], source_address: Tuple[str, int] = ...) -> 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 +# 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 def getaddrinfo( host: Optional[str], port: Union[str, int, None], family: int = ..., socktype: int = ..., proto: int = ..., - flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any]]]: + flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: ... def getfqdn(name: str = ...) -> str: ... From 7bf233c3b692d34210993f27612843057bd25714 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 14 Mar 2017 10:59:52 -0700 Subject: [PATCH 3/3] now it really works I tested it --- stdlib/3.4/asyncio/events.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3.4/asyncio/events.pyi b/stdlib/3.4/asyncio/events.pyi index 40c293f4f703..668705e98aaf 100644 --- a/stdlib/3.4/asyncio/events.pyi +++ b/stdlib/3.4/asyncio/events.pyi @@ -96,7 +96,7 @@ class AbstractEventLoop(metaclass=ABCMeta): # 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 def getaddrinfo(self, host: str, port: int, *, - family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ..]]]]: ... + family: int = ..., type: int = ..., proto: int = ..., flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ... @abstractmethod @coroutine def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...