From a6c5c21afaa6dcf33ce71027e8730354ee34e3b4 Mon Sep 17 00:00:00 2001 From: David Perl Date: Thu, 15 May 2025 08:49:01 +0200 Subject: [PATCH] style: typing in bec_dispatcher --- bec_widgets/utils/bec_dispatcher.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bec_widgets/utils/bec_dispatcher.py b/bec_widgets/utils/bec_dispatcher.py index 1ab6c15d..8c5690c1 100644 --- a/bec_widgets/utils/bec_dispatcher.py +++ b/bec_widgets/utils/bec_dispatcher.py @@ -163,7 +163,7 @@ class BECDispatcher: def connect_slot( self, slot: Callable, - topics: Union[EndpointInfo, str, list[Union[EndpointInfo, str]]], + topics: EndpointInfo | str | list[EndpointInfo] | list[str], cb_info: dict | None = None, **kwargs, ) -> None: @@ -172,7 +172,7 @@ class BECDispatcher: Args: slot (Callable): A slot method/function that accepts two inputs: content and metadata of the corresponding pub/sub message - topics (EndpointInfo | str | list): A topic or list of topics that can typically be acquired via bec_lib.MessageEndpoints + topics EndpointInfo | str | list[EndpointInfo] | list[str]: A topic or list of topics that can typically be acquired via bec_lib.MessageEndpoints cb_info (dict | None): A dictionary containing information about the callback. Defaults to None. """ qt_slot = QtThreadSafeCallback(cb=slot, cb_info=cb_info) @@ -183,13 +183,15 @@ class BECDispatcher: topics_str, _ = self.client.connector._convert_endpointinfo(topics) qt_slot.topics.update(set(topics_str)) - def disconnect_slot(self, slot: Callable, topics: Union[str, list]): + def disconnect_slot( + self, slot: Callable, topics: EndpointInfo | str | list[EndpointInfo] | list[str] + ): """ Disconnect a slot from a topic. Args: slot(Callable): The slot to disconnect - topics(Union[str, list]): The topic(s) to disconnect from + topics EndpointInfo | str | list[EndpointInfo] | list[str]: A topic or list of topics to unsub from. """ # find the right slot to disconnect from ; # slot callbacks are wrapped in QtThreadSafeCallback objects,