@@ -242,21 +242,10 @@ def start(self) -> None:
242242 """Start the background service."""
243243 self ._tasks .add (asyncio .create_task (self ._run ()))
244244
245- def _get_target_components_from_dispatch (
246- self , dispatch : Dispatch
247- ) -> TargetComponents :
248- if all (isinstance (comp , int ) for comp in dispatch .target ):
249- # We've confirmed all elements are integers, so we can cast.
250- int_components = cast (list [int ], dispatch .target )
251- return [ComponentId (cid ) for cid in int_components ]
252- # If not all are ints, then it must be a list of ComponentCategory
253- # based on the definition of ClientTargetComponents.
254- return cast (list [ComponentCategory ], dispatch .target )
255-
256245 async def _start_actor (self , dispatch : Dispatch ) -> None :
257246 """Start the actor the given dispatch refers to."""
258247 dispatch_update = DispatchInfo (
259- components = self . _get_target_components_from_dispatch (dispatch ),
248+ components = _convert_target_components (dispatch . target ),
260249 dry_run = dispatch .dry_run ,
261250 options = dispatch .payload ,
262251 _src = dispatch ,
@@ -337,3 +326,13 @@ async def _handle_dispatch(self, dispatch: Dispatch) -> None:
337326 await self ._start_actor (dispatch )
338327 else :
339328 await self ._stop_actor (dispatch , "Dispatch stopped" )
329+
330+
331+ def _convert_target_components (target : ClientTargetComponents ) -> TargetComponents :
332+ if all (isinstance (comp , int ) for comp in target ):
333+ # We've confirmed all elements are integers, so we can cast.
334+ int_components = cast (list [int ], target )
335+ return [ComponentId (cid ) for cid in int_components ]
336+ # If not all are ints, then it must be a list of ComponentCategory
337+ # based on the definition of ClientTargetComponents.
338+ return cast (list [ComponentCategory ], target )
0 commit comments