22import pickle
33import sys
44from dataclasses import dataclass , field
5- from typing import Any , Awaitable , Callable , Optional , Protocol , Union
5+ from typing import Any , Awaitable , Callable , Optional , Protocol , Union , List , Dict , Tuple , Set
66
77from typing_extensions import TypeAlias
88
@@ -84,9 +84,9 @@ def value(self) -> Any:
8484class AllFuture :
8585 """A future result of a dispatch.coroutine.all() operation."""
8686
87- order : list [CoroutineID ] = field (default_factory = list )
88- waiting : set [CoroutineID ] = field (default_factory = set )
89- results : dict [CoroutineID , CoroutineResult ] = field (default_factory = dict )
87+ order : List [CoroutineID ] = field (default_factory = list )
88+ waiting : Set [CoroutineID ] = field (default_factory = set )
89+ results : Dict [CoroutineID , CoroutineResult ] = field (default_factory = dict )
9090 first_error : Optional [Exception ] = None
9191
9292 def add_result (self , result : Union [CallResult , CoroutineResult ]):
@@ -115,7 +115,7 @@ def error(self) -> Optional[Exception]:
115115 assert self .ready ()
116116 return self .first_error
117117
118- def value (self ) -> list [Any ]:
118+ def value (self ) -> List [Any ]:
119119 assert self .ready ()
120120 assert len (self .waiting ) == 0
121121 assert self .first_error is None
@@ -126,10 +126,10 @@ def value(self) -> list[Any]:
126126class AnyFuture :
127127 """A future result of a dispatch.coroutine.any() operation."""
128128
129- order : list [CoroutineID ] = field (default_factory = list )
130- waiting : set [CoroutineID ] = field (default_factory = set )
129+ order : List [CoroutineID ] = field (default_factory = list )
130+ waiting : Set [CoroutineID ] = field (default_factory = set )
131131 first_result : Optional [CoroutineResult ] = None
132- errors : dict [CoroutineID , Exception ] = field (default_factory = dict )
132+ errors : Dict [CoroutineID , Exception ] = field (default_factory = dict )
133133 generic_error : Optional [Exception ] = None
134134
135135 def add_result (self , result : Union [CallResult , CoroutineResult ]):
@@ -183,7 +183,7 @@ def value(self) -> Any:
183183class RaceFuture :
184184 """A future result of a dispatch.coroutine.race() operation."""
185185
186- waiting : set [CoroutineID ] = field (default_factory = set )
186+ waiting : Set [CoroutineID ] = field (default_factory = set )
187187 first_result : Optional [CoroutineResult ] = None
188188 first_error : Optional [Exception ] = None
189189
@@ -248,12 +248,12 @@ class State:
248248 """State of the scheduler and the coroutines it's managing."""
249249
250250 version : str
251- suspended : dict [CoroutineID , Coroutine ]
252- ready : list [Coroutine ]
251+ suspended : Dict [CoroutineID , Coroutine ]
252+ ready : List [Coroutine ]
253253 next_coroutine_id : int
254254 next_call_id : int
255255
256- prev_callers : list [Coroutine ]
256+ prev_callers : List [Coroutine ]
257257
258258 outstanding_calls : int
259259
@@ -416,7 +416,7 @@ def _run(self, input: Input) -> Output:
416416 len (state .ready ) + len (state .suspended ),
417417 )
418418
419- pending_calls : list [Call ] = []
419+ pending_calls : List [Call ] = []
420420 while state .ready :
421421 coroutine = state .ready .pop (0 )
422422 logger .debug ("running %s" , coroutine )
@@ -542,8 +542,8 @@ def _run(self, input: Input) -> Output:
542542
543543
544544def spawn_children (
545- state : State , coroutine : Coroutine , awaitables : tuple [Awaitable [Any ], ...]
546- ) -> list [Coroutine ]:
545+ state : State , coroutine : Coroutine , awaitables : Tuple [Awaitable [Any ], ...]
546+ ) -> List [Coroutine ]:
547547 children = []
548548 for awaitable in awaitables :
549549 g = awaitable .__await__ ()
0 commit comments