mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Add overloads for asyncio.sleep() (#7873)
Closes #7866. This adds an overload to `asyncio.sleep()`, so that when it is called _without_ `return=None`, the type checker knows that the return type is `None` instead of `unknown`. Also related to https://github.com/microsoft/pyright/issues/3475.
This commit is contained in:
@@ -270,7 +270,10 @@ def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> con
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
def shield(arg: _FutureT[_T]) -> Future[_T]: ...
|
||||
async def sleep(delay: float, result: _T = ...) -> _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]
|
||||
@overload
|
||||
@@ -281,7 +284,10 @@ if sys.version_info >= (3, 10):
|
||||
|
||||
else:
|
||||
def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
|
||||
async def sleep(delay: float, result: _T = ..., *, loop: AbstractEventLoop | None = ...) -> _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]
|
||||
fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...
|
||||
|
||||
Reference in New Issue
Block a user