1313__all__ = ('new_event_loop' , 'install' , 'EventLoopPolicy' )
1414
1515
16+ _T = _typing .TypeVar ("_T" )
17+
18+
1619class Loop (__BaseLoop , __asyncio .AbstractEventLoop ): # type: ignore[misc]
1720 pass
1821
@@ -34,10 +37,25 @@ def install() -> None:
3437 __asyncio .set_event_loop_policy (EventLoopPolicy ())
3538
3639
37- def run (main , * , loop_factory = new_event_loop , debug = None , ** run_kwargs ):
40+ @_typing .overload
41+ def run (
42+ main : _typing .Coroutine [_typing .Any , _typing .Any , _T ],
43+ * ,
44+ debug : _typing .Optional [bool ] = ...,
45+ loop_factory : _typing .Optional [_typing .Callable [[], Loop ]] = ...,
46+ ) -> _T : ...
47+
48+
49+ def run (
50+ main : _typing .Coroutine [_typing .Any , _typing .Any , _T ],
51+ * ,
52+ loop_factory : _typing .Optional [_typing .Callable [[], Loop ]] = new_event_loop ,
53+ debug : _typing .Optional [bool ]= None ,
54+ ** run_kwargs : object
55+ ) -> _T :
3856 """The preferred way of running a coroutine with uvloop."""
3957
40- async def wrapper ():
58+ async def wrapper () -> _T :
4159 # If `loop_factory` is provided we want it to return
4260 # either uvloop.Loop or a subtype of it, assuming the user
4361 # is using `uvloop.run()` intentionally.
@@ -96,7 +114,7 @@ async def wrapper():
96114 )
97115
98116
99- def _cancel_all_tasks (loop ) :
117+ def _cancel_all_tasks (loop : __asyncio . AbstractEventLoop ) -> None :
100118 # Copied from python/cpython
101119
102120 to_cancel = __asyncio .all_tasks (loop )
0 commit comments