From: jrheard Date: Wed, 2 Apr 2025 21:52:02 +0000 (-0700) Subject: #3142: Improve usability of multi() and multi_future() type annotations X-Git-Tag: v6.5.0b1~3^2~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a10177cfacd056017a3715967fde4c9ee40cc39f;p=thirdparty%2Ftornado.git #3142: Improve usability of multi() and multi_future() type annotations --- diff --git a/tornado/gen.py b/tornado/gen.py index d12f32fb..e818e10c 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -91,7 +91,18 @@ except ImportError: contextvars = None # type: ignore import typing -from typing import Union, Any, Callable, List, Type, Tuple, Awaitable, Dict, overload +from typing import ( + Mapping, + Union, + Any, + Callable, + List, + Type, + Tuple, + Awaitable, + Dict, + overload, +) if typing.TYPE_CHECKING: from typing import Sequence, Deque, Optional, Set, Iterable # noqa: F401 @@ -426,7 +437,7 @@ class WaitIterator: def multi( - children: Union[List[_Yieldable], Dict[Any, _Yieldable]], + children: Union[Sequence[_Yieldable], Mapping[Any, _Yieldable]], quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> "Union[Future[List], Future[Dict]]": """Runs multiple asynchronous operations in parallel. @@ -480,7 +491,7 @@ Multi = multi def multi_future( - children: Union[List[_Yieldable], Dict[Any, _Yieldable]], + children: Union[Sequence[_Yieldable], Mapping[Any, _Yieldable]], quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> "Union[Future[List], Future[Dict]]": """Wait for multiple asynchronous futures in parallel.