Skip to content

Commit a10177c

Browse files
#3142: Improve usability of multi() and multi_future() type annotations
1 parent 0b7e700 commit a10177c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tornado/gen.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,18 @@ def get(self):
9191
contextvars = None # type: ignore
9292

9393
import typing
94-
from typing import Union, Any, Callable, List, Type, Tuple, Awaitable, Dict, overload
94+
from typing import (
95+
Mapping,
96+
Union,
97+
Any,
98+
Callable,
99+
List,
100+
Type,
101+
Tuple,
102+
Awaitable,
103+
Dict,
104+
overload,
105+
)
95106

96107
if typing.TYPE_CHECKING:
97108
from typing import Sequence, Deque, Optional, Set, Iterable # noqa: F401
@@ -426,7 +437,7 @@ def __anext__(self) -> Future:
426437

427438

428439
def multi(
429-
children: Union[List[_Yieldable], Dict[Any, _Yieldable]],
440+
children: Union[Sequence[_Yieldable], Mapping[Any, _Yieldable]],
430441
quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (),
431442
) -> "Union[Future[List], Future[Dict]]":
432443
"""Runs multiple asynchronous operations in parallel.
@@ -480,7 +491,7 @@ def multi(
480491

481492

482493
def multi_future(
483-
children: Union[List[_Yieldable], Dict[Any, _Yieldable]],
494+
children: Union[Sequence[_Yieldable], Mapping[Any, _Yieldable]],
484495
quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (),
485496
) -> "Union[Future[List], Future[Dict]]":
486497
"""Wait for multiple asynchronous futures in parallel.

0 commit comments

Comments
 (0)