From af9082c302fcc03bada0ba1cb16b5b2d9626657d Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 23 Feb 2019 19:04:15 +0100 Subject: [PATCH] Fix signature of asyncio.create_connection. (#2756) * local_addr and server_hostname are optional and default to None. * If sock is given, none of host, port, family, proto, flags and local_addr should be specified. --- stdlib/3/asyncio/events.pyi | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 052dc0bc8..a2f88dcf8 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -103,11 +103,18 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod @coroutine def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ... + @overload @abstractmethod @coroutine def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, - ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: Optional[socket] = ..., - local_addr: str = ..., server_hostname: str = ...) -> Generator[Any, None, _TransProtPair]: ... + ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ..., + local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ... + @overload + @abstractmethod + @coroutine + def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *, + ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket, + local_addr: None = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ... @overload @abstractmethod @coroutine @@ -121,7 +128,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @coroutine def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *, family: int = ..., flags: int = ..., - sock: socket = ..., backlog: int = ..., ssl: _SSLContext = ..., + sock: socket, backlog: int = ..., ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...) -> Generator[Any, None, AbstractServer]: ... @abstractmethod