api: Remove some mutable default arguments.
This could be more succinct with a conditional expression, but this is easier to read.
This commit is contained in:
parent
e786295352
commit
25d7e844a2
|
@ -344,10 +344,12 @@ class Client(object):
|
||||||
"status_code": res.status_code}
|
"status_code": res.status_code}
|
||||||
|
|
||||||
@classmethod
|
@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):
|
method="POST", computed_url=None, **query_kwargs):
|
||||||
if url is None:
|
if url is None:
|
||||||
url = name
|
url = name
|
||||||
|
if make_request is None:
|
||||||
|
make_request = lambda request=None: {} if request is None else request
|
||||||
def call(self, *args, **kwargs):
|
def call(self, *args, **kwargs):
|
||||||
request = make_request(*args, **kwargs)
|
request = make_request(*args, **kwargs)
|
||||||
if computed_url is not None:
|
if computed_url is not None:
|
||||||
|
@ -358,7 +360,9 @@ class Client(object):
|
||||||
call.__name__ = name
|
call.__name__ = name
|
||||||
setattr(cls, name, call)
|
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():
|
def do_register():
|
||||||
while True:
|
while True:
|
||||||
if event_types is None:
|
if event_types is None:
|
||||||
|
@ -426,9 +430,11 @@ def _mk_rm_subs(streams):
|
||||||
def _mk_deregister(queue_id):
|
def _mk_deregister(queue_id):
|
||||||
return {'queue_id': 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:
|
if event_types is None:
|
||||||
return dict()
|
return dict()
|
||||||
|
if narrow is None:
|
||||||
|
narrow = []
|
||||||
return dict(event_types=event_types, narrow=narrow)
|
return dict(event_types=event_types, narrow=narrow)
|
||||||
|
|
||||||
def _kwargs_to_dict(**kwargs):
|
def _kwargs_to_dict(**kwargs):
|
||||||
|
|
Loading…
Reference in a new issue