mirror of https://github.com/zulip/zulip.git
Remove some mutable default arguments.
These ones don't fix any bugs, because the mutable arg is never passed outside of the callable or mutated. But it's good practice to not use them in case those invariants are changed in the future.
This commit is contained in:
parent
2e4283f60a
commit
5fe9076631
|
@ -86,13 +86,13 @@ def check_pyflakes():
|
||||||
failed = True
|
failed = True
|
||||||
return failed
|
return failed
|
||||||
|
|
||||||
def custom_check_file(fn, rules, skip_rules=[]):
|
def custom_check_file(fn, rules, skip_rules=None):
|
||||||
failed = False
|
failed = False
|
||||||
lineFlag = False
|
lineFlag = False
|
||||||
for i, line in enumerate(open(fn)):
|
for i, line in enumerate(open(fn)):
|
||||||
skip = False
|
skip = False
|
||||||
lineFlag = True
|
lineFlag = True
|
||||||
for rule in skip_rules:
|
for rule in skip_rules or []:
|
||||||
if re.match(rule, line):
|
if re.match(rule, line):
|
||||||
skip = True
|
skip = True
|
||||||
if skip:
|
if skip:
|
||||||
|
@ -183,7 +183,7 @@ python_rules = [
|
||||||
'exclude': set(['tools/lint-all']),
|
'exclude': set(['tools/lint-all']),
|
||||||
'exclude_line': set([
|
'exclude_line': set([
|
||||||
# function definition
|
# function definition
|
||||||
('zerver/lib/response.py', 'def json_error(msg, data={}, status=400):'),
|
('zerver/lib/response.py', 'def json_error(msg, data=None, status=400):'),
|
||||||
# No need to worry about the following as the translation strings
|
# No need to worry about the following as the translation strings
|
||||||
# are already captured
|
# are already captured
|
||||||
('zerver/middleware.py',
|
('zerver/middleware.py',
|
||||||
|
|
|
@ -23,16 +23,17 @@ def json_method_not_allowed(methods):
|
||||||
"allowed_methods": methods})
|
"allowed_methods": methods})
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def json_response(res_type="success", msg="", data={}, status=200):
|
def json_response(res_type="success", msg="", data=None, status=200):
|
||||||
content = {"result": res_type, "msg": msg}
|
content = {"result": res_type, "msg": msg}
|
||||||
content.update(data)
|
if data is not None:
|
||||||
|
content.update(data)
|
||||||
return HttpResponse(content=ujson.dumps(content) + "\n",
|
return HttpResponse(content=ujson.dumps(content) + "\n",
|
||||||
content_type='application/json', status=status)
|
content_type='application/json', status=status)
|
||||||
|
|
||||||
def json_success(data={}):
|
def json_success(data=None):
|
||||||
return json_response(data=data)
|
return json_response(data=data)
|
||||||
|
|
||||||
def json_error(msg, data={}, status=400):
|
def json_error(msg, data=None, status=400):
|
||||||
return json_response(res_type="error", msg=msg, data=data, status=status)
|
return json_response(res_type="error", msg=msg, data=data, status=status)
|
||||||
|
|
||||||
def json_unhandled_exception():
|
def json_unhandled_exception():
|
||||||
|
|
Loading…
Reference in New Issue