asyncio.gather: Add overload for if no positional arguments are provided (#8126)

This commit is contained in:
Alex Waygood
2022-06-21 15:31:40 +01:00
committed by GitHub
parent a01e0260b3
commit 0740d1c48e

View File

@@ -86,6 +86,8 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No
# zip() because typing does not support variadic type variables. See
# typing PR #1550 for discussion.
if sys.version_info >= (3, 10):
@overload
def gather(*, return_exceptions: bool = ...) -> Future[tuple[()]]: ...
@overload
def gather(__coro_or_future1: _FutureT[_T1], *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]: ...
@overload
@@ -120,17 +122,6 @@ if sys.version_info >= (3, 10):
return_exceptions: Literal[False] = ...,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather(
__coro_or_future1: _FutureT[Any],
__coro_or_future2: _FutureT[Any],
__coro_or_future3: _FutureT[Any],
__coro_or_future4: _FutureT[Any],
__coro_or_future5: _FutureT[Any],
__coro_or_future6: _FutureT[Any],
*coros_or_futures: _FutureT[Any],
return_exceptions: bool = ...,
) -> Future[list[Any]]: ...
@overload
def gather(__coro_or_future1: _FutureT[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ...
@overload
def gather(
@@ -165,8 +156,21 @@ if sys.version_info >= (3, 10):
) -> Future[
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather(
__coro_or_future1: _FutureT[Any],
__coro_or_future2: _FutureT[Any],
__coro_or_future3: _FutureT[Any],
__coro_or_future4: _FutureT[Any],
__coro_or_future5: _FutureT[Any],
__coro_or_future6: _FutureT[Any],
*coros_or_futures: _FutureT[Any],
return_exceptions: bool = ...,
) -> Future[list[Any]]: ...
else:
@overload
def gather(*, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ...) -> Future[tuple[()]]: ...
@overload
def gather(
__coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ...
@@ -210,18 +214,6 @@ else:
return_exceptions: Literal[False] = ...,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather(
__coro_or_future1: _FutureT[Any],
__coro_or_future2: _FutureT[Any],
__coro_or_future3: _FutureT[Any],
__coro_or_future4: _FutureT[Any],
__coro_or_future5: _FutureT[Any],
__coro_or_future6: _FutureT[Any],
*coros_or_futures: _FutureT[Any],
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[list[Any]]: ...
@overload
def gather(
__coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool
) -> Future[tuple[_T1 | BaseException]]: ...
@@ -265,6 +257,18 @@ else:
) -> Future[
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather(
__coro_or_future1: _FutureT[Any],
__coro_or_future2: _FutureT[Any],
__coro_or_future3: _FutureT[Any],
__coro_or_future4: _FutureT[Any],
__coro_or_future5: _FutureT[Any],
__coro_or_future6: _FutureT[Any],
*coros_or_futures: _FutureT[Any],
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[list[Any]]: ...
def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...