From 14abe021f7f3950de3f71a3634bf76359f0e927f Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Wed, 18 May 2022 17:52:16 -0500 Subject: [PATCH] Add overloads for asyncio.sleep(). Closes #7866 --- stdlib/asyncio/tasks.pyi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 2e483753a4d0..d06b2097b0ad 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -270,6 +270,9 @@ def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> con if sys.version_info >= (3, 10): def shield(arg: _FutureT[_T]) -> Future[_T]: ... + @overload + async def sleep(delay: float) -> None: ... + @overload async def sleep(delay: float, result: _T = ...) -> _T: ... @overload async def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> tuple[set[_FT], set[_FT]]: ... # type: ignore[misc] @@ -281,6 +284,9 @@ if sys.version_info >= (3, 10): else: def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... + @overload + async def sleep(delay: float, *, loop: AbstractEventLoop | None = ...) -> None: ... + @overload async def sleep(delay: float, result: _T = ..., *, loop: AbstractEventLoop | None = ...) -> _T: ... @overload async def wait( # type: ignore[misc]