From 370aa58f8ea4b62a75b368d81ce1b51cf4272128 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 10:52:38 +0200 Subject: [PATCH 01/11] Add explicit ssl_handshake_timeout arguments to open_connection and start_server --- stdlib/3/asyncio/streams.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/3/asyncio/streams.pyi b/stdlib/3/asyncio/streams.pyi index c3c8569ca5e2..5f5870b86c86 100644 --- a/stdlib/3/asyncio/streams.pyi +++ b/stdlib/3/asyncio/streams.pyi @@ -25,6 +25,7 @@ def open_connection( *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., + ssl_handshake_timeout: Optional[float] = ..., **kwds: Any ) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ... @@ -36,6 +37,7 @@ def start_server( *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., + ssl_handshake_timeout: Optional[float] = ..., **kwds: Any ) -> Generator[Any, None, events.AbstractServer]: ... From 067feef9faf77edaa04eeb8a2b075f79c402fc19 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 10:52:53 +0200 Subject: [PATCH 02/11] Add context arguments to call methods --- stdlib/3/asyncio/base_events.pyi | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index 8210ebded19a..da780b48e57a 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -11,6 +11,9 @@ from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport +if sys.version_info >= (3, 7): + from contextvars import Context + _T = TypeVar('_T') _Context = Dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] @@ -37,9 +40,18 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): @coroutine def shutdown_asyncgens(self) -> Generator[Any, None, None]: ... # Methods scheduling callbacks. All these return Handles. - def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ... - def call_later(self, delay: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... - def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... + if sys.version_info >= (3, 7): + def call_soon(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ... + def call_later( + self, delay: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ..., + ) -> TimerHandle: ... + def call_at( + self, when: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ..., + ) -> TimerHandle: ... + else: + def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ... + def call_later(self, delay: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... + def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... def time(self) -> float: ... # Future methods def create_future(self) -> Future[Any]: ... @@ -53,7 +65,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ... def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ... # Methods for interacting with threads - def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... + if sys.version_info >= (3, 7): + def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ... + else: + def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... @coroutine def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Generator[Any, None, _T]: ... From b6d4ca0dab1d37dfd6598c1ecb22a46ded87678d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:10:38 +0200 Subject: [PATCH 03/11] Accept PathLike for create_unix_* paths --- stdlib/3/asyncio/proactor_events.pyi | 35 ++++++++++++++++++++++------ stdlib/3/asyncio/selector_events.pyi | 34 +++++++++++++++++++++------ 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/stdlib/3/asyncio/proactor_events.pyi b/stdlib/3/asyncio/proactor_events.pyi index bed374734f02..2e8308ff0a5d 100644 --- a/stdlib/3/asyncio/proactor_events.pyi +++ b/stdlib/3/asyncio/proactor_events.pyi @@ -1,9 +1,15 @@ - +from os import PathLike from typing import Any, Mapping, Optional, Generator from . import base_events, transports, events, streams, futures, constants from asyncio import coroutine from socket import socket import sys + +if sys.version_info >= (3, 7): + _Path = Union[str, PathLike[str]] +else: + _Path = str + if sys.version_info >= (3, 8): from typing import Literal else: @@ -45,12 +51,27 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): # The methods below don't actually exist directly, ProactorEventLoops do not implement them. However, they are # needed to satisfy mypy if sys.version_info >= (3, 7): - async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ..., - sock: Optional[socket] = ..., server_hostname: str = ..., - ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ... - async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ..., - backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ..., - start_serving: bool = ...) -> events.AbstractServer: ... + async def create_unix_connection( + self, + protocol_factory: events._ProtocolFactory, + path: _Path, + *, + ssl: events._SSLContext = ..., + sock: Optional[socket] = ..., + server_hostname: str = ..., + ssl_handshake_timeout: Optional[float] = ..., + ) -> events._TransProtPair: ... + async def create_unix_server( + self, + protocol_factory: events._ProtocolFactory, + path: _Path, + *, + sock: Optional[socket] = ..., + backlog: int = ..., + ssl: events._SSLContext = ..., + ssl_handshake_timeout: Optional[float] = ..., + start_serving: bool = ..., + ) -> events.AbstractServer: ... else: @coroutine def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, diff --git a/stdlib/3/asyncio/selector_events.pyi b/stdlib/3/asyncio/selector_events.pyi index 42381de74005..79724dd83a7c 100644 --- a/stdlib/3/asyncio/selector_events.pyi +++ b/stdlib/3/asyncio/selector_events.pyi @@ -1,4 +1,4 @@ - +from os import PathLike from typing import Optional, Any, Generator from . import base_events, events from socket import socket @@ -6,16 +6,36 @@ from asyncio import coroutine import selectors import sys +if sys.version_info >= (3, 7): + _Path = Union[str, PathLike[str]] +else: + _Path = str + class BaseSelectorEventLoop(base_events.BaseEventLoop): def __init__(self, selector: selectors.BaseSelector = ...) -> None: ... if sys.version_info >= (3, 7): - async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ..., - sock: Optional[socket] = ..., server_hostname: str = ..., - ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ... - async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ..., - backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ..., - start_serving: bool = ...) -> events.AbstractServer: ... + async def create_unix_connection( + self, + protocol_factory: events._ProtocolFactory, + path: _Path, + *, + ssl: events._SSLContext = ..., + sock: Optional[socket] = ..., + server_hostname: str = ..., + ssl_handshake_timeout: Optional[float] = ..., + ) -> events._TransProtPair: ... + async def create_unix_server( + self, + protocol_factory: events._ProtocolFactory, + path: _Path, + *, + sock: Optional[socket] = ..., + backlog: int = ..., + ssl: events._SSLContext = ..., + ssl_handshake_timeout: Optional[float] = ..., + start_serving: bool = ..., + ) -> events.AbstractServer: ... else: @coroutine def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, From e39d7713a83ccbd65f8663c04a07ca72595b4f1c Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:15:53 +0200 Subject: [PATCH 04/11] Add TimerHandle.when() Add missing version check --- stdlib/3/asyncio/events.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 977bef092dee..2453c061cfec 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -24,12 +24,15 @@ class Handle: def __repr__(self) -> str: ... def cancel(self) -> None: ... def _run(self) -> None: ... - def cancelled(self) -> bool: ... + if sys.version_info >= (3, 7): + def cancelled(self) -> bool: ... class TimerHandle(Handle): def __init__(self, when: float, callback: Callable[..., Any], args: List[Any], loop: AbstractEventLoop) -> None: ... def __hash__(self) -> int: ... + if sys.version_info >= (3, 7): + def when(self) -> float: ... class AbstractServer: sockets: Optional[List[socket]] From 726fb15099adecf5e34f5f7b2b47623ecfd5553c Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:19:07 +0200 Subject: [PATCH 05/11] AbstractServer is now an async context manager --- stdlib/3/asyncio/events.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 2453c061cfec..52affef4e9ba 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -38,6 +38,8 @@ class AbstractServer: sockets: Optional[List[socket]] def close(self) -> None: ... if sys.version_info >= (3, 7): + async def __aenter__(self: _T) -> _T: ... + async def __aexit__(self, *exc: Any) -> None: ... def get_loop(self) -> AbstractEventLoop: ... def is_serving(self) -> bool: ... async def start_serving(self) -> None: ... From 3db0edfceeea40b15eec489961b27326f5f45e32 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:28:40 +0200 Subject: [PATCH 06/11] Add happy_eyeballs_delay and interleave arguments to create_connection --- stdlib/3/asyncio/base_events.pyi | 65 +++++++++++++++++++++++------ stdlib/3/asyncio/events.pyi | 71 +++++++++++++++++++++++++------- 2 files changed, 108 insertions(+), 28 deletions(-) diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index da780b48e57a..79d32fab2c7c 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -82,9 +82,44 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ... @coroutine def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ... - if sys.version_info >= (3, 7): - async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, - fallback: bool = ...) -> int: ... + if sys.version_info >= (3, 8): + @overload + async def create_connection( + self, + protocol_factory: _ProtocolFactory, + host: str = ..., + port: int = ..., + *, + ssl: _SSLContext = ..., + family: int = ..., + proto: int = ..., + flags: int = ..., + sock: None = ..., + local_addr: Optional[str] = ..., + server_hostname: Optional[str] = ..., + ssl_handshake_timeout: Optional[float] = ..., + happy_eyeballs_delay: Optional[float] = ..., + interleave: Optional[int] = ..., + ) -> _TransProtPair: ... + @overload + async 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] = ..., + ssl_handshake_timeout: Optional[float] = ..., + happy_eyeballs_delay: Optional[float] = ..., + interleave: Optional[int] = ..., + ) -> _TransProtPair: ... + elif sys.version_info >= (3, 7): @overload async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., @@ -95,6 +130,20 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket, local_addr: None = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ... + else: + @overload + @coroutine + def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, + ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ..., + local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ... + @overload + @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]: ... + if sys.version_info >= (3, 7): + async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, + fallback: bool = ...) -> int: ... @overload async def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ..., @@ -115,16 +164,6 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): else: @overload @coroutine - def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, - ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ... - @overload - @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 - @coroutine def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ..., ssl: _SSLContext = ..., diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 52affef4e9ba..5535ecb8a8d8 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -117,10 +117,46 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod @coroutine def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ... - if sys.version_info >= (3, 7): + if sys.version_info >= (3, 8): + @overload @abstractmethod - async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, - fallback: bool = ...) -> int: ... + async def create_connection( + self, + protocol_factory: _ProtocolFactory, + host: str = ..., + port: int = ..., + *, + ssl: _SSLContext = ..., + family: int = ..., + proto: int = ..., + flags: int = ..., + sock: None = ..., + local_addr: Optional[str] = ..., + server_hostname: Optional[str] = ..., + ssl_handshake_timeout: Optional[float] = ..., + happy_eyeballs_delay: Optional[float] = ..., + interleave: Optional[int] = ..., + ) -> _TransProtPair: ... + @overload + @abstractmethod + async 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] = ..., + ssl_handshake_timeout: Optional[float] = ..., + happy_eyeballs_delay: Optional[float] = ..., + interleave: Optional[int] = ..., + ) -> _TransProtPair: ... + elif sys.version_info >= (3, 7): @overload @abstractmethod async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, @@ -133,6 +169,23 @@ class AbstractEventLoop(metaclass=ABCMeta): ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket, local_addr: None = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ... + else: + @overload + @abstractmethod + @coroutine + def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, + 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]: ... + if sys.version_info >= (3, 7): + @abstractmethod + async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, + fallback: bool = ...) -> int: ... @overload @abstractmethod async def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., @@ -167,18 +220,6 @@ class AbstractEventLoop(metaclass=ABCMeta): @overload @abstractmethod @coroutine - def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, - 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 def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ..., ssl: _SSLContext = ..., From c16083d2eb61935d47581de2b8210866fa84fdbc Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:31:39 +0200 Subject: [PATCH 07/11] Re-export asyncio.windows_events from asyncio --- stdlib/3/asyncio/__init__.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/3/asyncio/__init__.pyi b/stdlib/3/asyncio/__init__.pyi index 43e3be9e2d1e..4a6c8ab2a00e 100644 --- a/stdlib/3/asyncio/__init__.pyi +++ b/stdlib/3/asyncio/__init__.pyi @@ -87,7 +87,9 @@ from asyncio.events import ( _set_running_loop as _set_running_loop, _get_running_loop as _get_running_loop, ) -if sys.platform != 'win32': +if sys.platform == 'win32': + from asyncio.windows_events import * +else: from asyncio.streams import ( open_unix_connection as open_unix_connection, start_unix_server as start_unix_server, @@ -111,8 +113,6 @@ if sys.version_info >= (3, 7): # currently disallows this. # See https://github.com/python/mypy/issues/1843 SelectorEventLoop: Type[AbstractEventLoop] -if sys.platform == 'win32': - ProactorEventLoop: Type[AbstractEventLoop] DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] # TODO: AbstractChildWatcher (UNIX only) From 4ee538aecf2fbace73891442b65ba3018b863b1d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:35:31 +0200 Subject: [PATCH 08/11] Add name argument to Task constructor --- stdlib/3/asyncio/tasks.pyi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index 65c28ebe68e5..28ff751bbd59 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -96,7 +96,16 @@ class Task(Future[_T], Generic[_T]): def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Task[Any]: ... @classmethod def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... - def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + coro: Union[Generator[Any, None, _T], Awaitable[_T]], + *, + loop: AbstractEventLoop = ..., + name: Optional[str] = ..., + ) -> None: ... + else: + def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): def get_name(self) -> str: ... From 1283d229885a26f7c6c155e709ba958a4ddcdbf0 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 11:36:25 +0200 Subject: [PATCH 09/11] Add Task.get_coro() --- stdlib/3/asyncio/tasks.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index 28ff751bbd59..feab8db1344c 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -108,6 +108,7 @@ class Task(Future[_T], Generic[_T]): def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): + def get_coro(self) -> Task: ... def get_name(self) -> str: ... def set_name(self, value: object) -> None: ... def get_stack(self, *, limit: int = ...) -> List[FrameType]: ... From 9dde54aefd8b63787f48e1b2b6c0a29a78a40a37 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 23 Oct 2019 12:04:28 +0200 Subject: [PATCH 10/11] import and other fixes --- stdlib/3/asyncio/proactor_events.pyi | 11 ++++++----- stdlib/3/asyncio/selector_events.pyi | 11 ++++++----- stdlib/3/asyncio/tasks.pyi | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/stdlib/3/asyncio/proactor_events.pyi b/stdlib/3/asyncio/proactor_events.pyi index 2e8308ff0a5d..2cfa49de6ed7 100644 --- a/stdlib/3/asyncio/proactor_events.pyi +++ b/stdlib/3/asyncio/proactor_events.pyi @@ -1,11 +1,12 @@ -from os import PathLike -from typing import Any, Mapping, Optional, Generator -from . import base_events, transports, events, streams, futures, constants +import sys from asyncio import coroutine from socket import socket -import sys +from typing import Any, Generator, Mapping, Optional, Union + +from . import base_events, constants, events, futures, streams, transports if sys.version_info >= (3, 7): + from os import PathLike _Path = Union[str, PathLike[str]] else: _Path = str @@ -54,7 +55,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): async def create_unix_connection( self, protocol_factory: events._ProtocolFactory, - path: _Path, + path: _Path, *, ssl: events._SSLContext = ..., sock: Optional[socket] = ..., diff --git a/stdlib/3/asyncio/selector_events.pyi b/stdlib/3/asyncio/selector_events.pyi index 79724dd83a7c..c5edd79228da 100644 --- a/stdlib/3/asyncio/selector_events.pyi +++ b/stdlib/3/asyncio/selector_events.pyi @@ -1,12 +1,13 @@ -from os import PathLike -from typing import Optional, Any, Generator -from . import base_events, events -from socket import socket -from asyncio import coroutine import selectors import sys +from asyncio import coroutine +from socket import socket +from typing import Any, Generator, Optional, Union + +from . import base_events, events if sys.version_info >= (3, 7): + from os import PathLike _Path = Union[str, PathLike[str]] else: _Path = str diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index feab8db1344c..7cf4af8d2b0f 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -108,7 +108,7 @@ class Task(Future[_T], Generic[_T]): def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): - def get_coro(self) -> Task: ... + def get_coro(self) -> Task[_T]: ... def get_name(self) -> str: ... def set_name(self, value: object) -> None: ... def get_stack(self, *, limit: int = ...) -> List[FrameType]: ... From 720aa2205ec4e840010c8be7ae9b0ee78c87521d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 25 Oct 2019 11:36:31 +0200 Subject: [PATCH 11/11] Fix return type of get_coro() --- stdlib/3/asyncio/tasks.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index 7cf4af8d2b0f..28614687ab74 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -108,7 +108,7 @@ class Task(Future[_T], Generic[_T]): def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): - def get_coro(self) -> Task[_T]: ... + def get_coro(self) -> Any: ... def get_name(self) -> str: ... def set_name(self, value: object) -> None: ... def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...