From 2a2c8ae25f566306082b354191d01d0b505f7b69 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sun, 7 Jan 2018 04:26:25 -0800 Subject: [PATCH] API: Amend call_on_each_event error handling to not use .get(). mypy with strict-optional led to examination of res.get('result') calls potentially raising TypeError ('error' in None). Server code indicates this is safe, and other nearby code assumes presence of fields in 'res' also. --- zulip/zulip/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 589e92c..1247dd8 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -588,7 +588,7 @@ class Client(object): else: res = self.register(event_types=event_types, narrow=narrow) - if 'error' in res.get('result'): + if 'error' in res['result']: if self.verbose: print("Server returned error:\n%s" % res['msg']) time.sleep(1) @@ -604,7 +604,7 @@ class Client(object): (queue_id, last_event_id) = do_register() res = self.get_events(queue_id=queue_id, last_event_id=last_event_id) - if 'error' in res.get('result'): + if 'error' in res['result']: if res["result"] == "http-error": if self.verbose: print("HTTP error fetching events -- probably a server restart")