From 25d7e844a29f543b6cbb1b50ceb5fa010dd8c672 Mon Sep 17 00:00:00 2001 From: Nathan Florea Date: Thu, 2 Jun 2016 15:53:09 -0700 Subject: [PATCH] api: Remove some mutable default arguments. This could be more succinct with a conditional expression, but this is easier to read. --- zulip/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index 6431f30..1e64a46 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -344,10 +344,12 @@ class Client(object): "status_code": res.status_code} @classmethod - def _register(cls, name, url=None, make_request=(lambda request={}: request), + def _register(cls, name, url=None, make_request=None, method="POST", computed_url=None, **query_kwargs): if url is None: url = name + if make_request is None: + make_request = lambda request=None: {} if request is None else request def call(self, *args, **kwargs): request = make_request(*args, **kwargs) if computed_url is not None: @@ -358,7 +360,9 @@ class Client(object): call.__name__ = name setattr(cls, name, call) - def call_on_each_event(self, callback, event_types=None, narrow=[]): + def call_on_each_event(self, callback, event_types=None, narrow=None): + if narrow is None: + narrow = [] def do_register(): while True: if event_types is None: @@ -426,9 +430,11 @@ def _mk_rm_subs(streams): def _mk_deregister(queue_id): return {'queue_id': queue_id} -def _mk_events(event_types=None, narrow=[]): +def _mk_events(event_types=None, narrow=None): if event_types is None: return dict() + if narrow is None: + narrow = [] return dict(event_types=event_types, narrow=narrow) def _kwargs_to_dict(**kwargs):