@@ -37,25 +37,26 @@ async def dispatch_single_view(
3737 task_group .start_soon (_single_incoming_loop , layout , recv )
3838
3939
40- _SharedDispatchFuture = Callable [[SendCoroutine , RecvCoroutine ], Future ]
40+ _SharedViewDispatcherFuture = Callable [[SendCoroutine , RecvCoroutine ], Future [None ]]
41+ _SharedViewDispatcherCoro = Callable [[SendCoroutine , RecvCoroutine ], Awaitable [None ]]
4142
4243
4344@asynccontextmanager
4445async def create_shared_view_dispatcher (
4546 layout : Layout , run_forever : bool = False
46- ) -> AsyncIterator [_SharedDispatchFuture ]:
47+ ) -> AsyncIterator [_SharedViewDispatcherFuture ]:
4748 with layout :
4849 (
4950 dispatch_shared_view ,
5051 model_state ,
5152 all_update_queues ,
5253 ) = await _make_shared_view_dispatcher (layout )
5354
54- dispatch_tasks : List [Future ] = []
55+ dispatch_tasks : List [Future [ None ] ] = []
5556
5657 def dispatch_shared_view_soon (
5758 send : SendCoroutine , recv : RecvCoroutine
58- ) -> Future :
59+ ) -> Future [ None ] :
5960 future = ensure_future (dispatch_shared_view (send , recv ))
6061 dispatch_tasks .append (future )
6162 return future
@@ -87,10 +88,10 @@ def dispatch_shared_view_soon(
8788
8889def ensure_shared_view_dispatcher_future (
8990 layout : Layout ,
90- ) -> Tuple [Future , _SharedDispatchFuture ]:
91- dispatcher_future = Future ()
91+ ) -> Tuple [Future [ None ], _SharedViewDispatcherCoro ]:
92+ dispatcher_future : Future [ _SharedViewDispatcherCoro ] = Future ()
9293
93- async def dispatch_shared_view_forever ():
94+ async def dispatch_shared_view_forever () -> None :
9495 with layout :
9596 (
9697 dispatch_shared_view ,
@@ -113,12 +114,9 @@ async def dispatch(send: SendCoroutine, recv: RecvCoroutine) -> None:
113114 return ensure_future (dispatch_shared_view_forever ()), dispatch
114115
115116
116- _SharedDispatchCoroutine = Callable [[SendCoroutine , RecvCoroutine ], Awaitable [None ]]
117-
118-
119117async def _make_shared_view_dispatcher (
120118 layout : Layout ,
121- ) -> Tuple [_SharedDispatchCoroutine , Ref [Any ], WeakSet [Queue [LayoutUpdate ]]]:
119+ ) -> Tuple [_SharedViewDispatcherCoro , Ref [Any ], WeakSet [Queue [LayoutUpdate ]]]:
122120 initial_update = await layout .render ()
123121 model_state = Ref (initial_update .apply_to ({}))
124122
@@ -158,7 +156,7 @@ async def _shared_outgoing_loop(
158156
159157async def _wait_until_first_complete (
160158 * tasks : Awaitable [Any ],
161- ) -> Sequence [Future ]:
159+ ) -> Sequence [Future [ Any ] ]:
162160 futures = [ensure_future (t ) for t in tasks ]
163161 await wait (futures , return_when = FIRST_COMPLETED )
164162 return futures
0 commit comments