From 70f457f82ab3e2fa6fc489f950e46e105dc27ae3 Mon Sep 17 00:00:00 2001 From: LoopThrough-i-j Date: Wed, 10 Mar 2021 22:46:56 +0530 Subject: [PATCH] zulip: Add support for additional args for `Client.call_on_each_*`. - Added `**kwargs` typed `object` in the definition of `Client.call_on_each_*` . - Replaced `**kwargs` type from `Any` to `object` in the definition of `Client.register`. Fixes part of #647 --- zulip/zulip/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index d5130db..18f523a 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -617,17 +617,17 @@ class Client: callback: Callable[[Dict[str, Any]], None], event_types: Optional[List[str]] = None, narrow: Optional[List[List[str]]] = None, + **kwargs: object, ) -> None: if narrow is None: narrow = [] def do_register() -> Tuple[str, int]: - while True: - if event_types is None: - res = self.register() - else: - res = self.register(event_types=event_types, narrow=narrow) + if event_types is None: + narrow = None + while True: + res = self.register(event_types, narrow, **kwargs) if 'error' in res['result']: if self.verbose: print("Server returned error:\n%s" % (res['msg'],)) @@ -679,11 +679,11 @@ class Client: last_event_id = max(last_event_id, int(event['id'])) callback(event) - def call_on_each_message(self, callback: Callable[[Dict[str, Any]], None]) -> None: + def call_on_each_message(self, callback: Callable[[Dict[str, Any]], None], **kwargs: object) -> None: def event_callback(event: Dict[str, Any]) -> None: if event['type'] == 'message': callback(event['message']) - self.call_on_each_event(event_callback, ['message']) + self.call_on_each_event(event_callback, ['message'], None, **kwargs) def get_messages(self, message_filters: Dict[str, Any]) -> Dict[str, Any]: ''' @@ -1029,7 +1029,7 @@ class Client: self, event_types: Optional[Iterable[str]] = None, narrow: Optional[List[List[str]]] = None, - **kwargs: Any + **kwargs: object ) -> Dict[str, Any]: ''' Example usage: