]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
#3142: Improve usability of multi() and multi_future() type annotations
authorjrheard <jrheard@seesaw.me>
Wed, 2 Apr 2025 21:52:02 +0000 (14:52 -0700)
committerjrheard <jrheard@seesaw.me>
Wed, 2 Apr 2025 21:52:02 +0000 (14:52 -0700)
tornado/gen.py

index d12f32fbd86918f69c276bf3e0674210535b0435..e818e10c3000ef822acdf90c4b12cdaab494ad8d 100644 (file)
@@ -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.