Skip to content

Commit 5639d49

Browse files
authored
Merge pull request #3478 from jrheard-seesaw/3142-gen-multi-typing
#3142: Improve usability of multi() and multi_future() type annotations
2 parents 26405b5 + b29866a commit 5639d49

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

tornado/gen.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,22 @@ 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+
Sequence,
105+
overload,
106+
)
95107

96108
if typing.TYPE_CHECKING:
97-
from typing import Sequence, Deque, Optional, Set, Iterable # noqa: F401
109+
from typing import Deque, Optional, Set, Iterable # noqa: F401
98110

99111
_T = typing.TypeVar("_T")
100112

@@ -426,7 +438,7 @@ def __anext__(self) -> Future:
426438

427439

428440
def multi(
429-
children: Union[List[_Yieldable], Dict[Any, _Yieldable]],
441+
children: Union[Sequence[_Yieldable], Mapping[Any, _Yieldable]],
430442
quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (),
431443
) -> "Union[Future[List], Future[Dict]]":
432444
"""Runs multiple asynchronous operations in parallel.
@@ -480,7 +492,7 @@ def multi(
480492

481493

482494
def multi_future(
483-
children: Union[List[_Yieldable], Dict[Any, _Yieldable]],
495+
children: Union[Sequence[_Yieldable], Mapping[Any, _Yieldable]],
484496
quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (),
485497
) -> "Union[Future[List], Future[Dict]]":
486498
"""Wait for multiple asynchronous futures in parallel.

0 commit comments

Comments
 (0)