Skip to content

Commit cc8ca93

Browse files
Fix type for run_coroutine_threadsafe (#13498)
1 parent 3f41b30 commit cc8ca93

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/asyncio/tasks.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ if sys.version_info >= (3, 12):
7979
_FutureLike: TypeAlias = Future[_T] | Awaitable[_T]
8080
else:
8181
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
82+
8283
_TaskYieldType: TypeAlias = Future[object] | None
8384

8485
FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
@@ -347,7 +348,8 @@ else:
347348
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool
348349
) -> Future[list[_T | BaseException]]: ...
349350

350-
def run_coroutine_threadsafe(coro: _FutureLike[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
351+
# unlike some asyncio apis, This does strict runtime checking of actually being a coroutine, not of any future-like.
352+
def run_coroutine_threadsafe(coro: Coroutine[Any, Any, _T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
351353

352354
if sys.version_info >= (3, 10):
353355
def shield(arg: _FutureLike[_T]) -> Future[_T]: ...

0 commit comments

Comments
 (0)