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:
Nathan Florea 2016-06-02 16:04:39 -07:00 committed by Tim Abbott
parent 2e4283f60a
commit 5fe9076631
2 changed files with 8 additions and 7 deletions

View File

@ -86,13 +86,13 @@ def check_pyflakes():
failed = True
return failed
def custom_check_file(fn, rules, skip_rules=[]):
def custom_check_file(fn, rules, skip_rules=None):
failed = False
lineFlag = False
for i, line in enumerate(open(fn)):
skip = False
lineFlag = True
for rule in skip_rules:
for rule in skip_rules or []:
if re.match(rule, line):
skip = True
if skip:
@ -183,7 +183,7 @@ python_rules = [
'exclude': set(['tools/lint-all']),
'exclude_line': set([
# 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
# are already captured
('zerver/middleware.py',

View File

@ -23,16 +23,17 @@ def json_method_not_allowed(methods):
"allowed_methods": methods})
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.update(data)
if data is not None:
content.update(data)
return HttpResponse(content=ujson.dumps(content) + "\n",
content_type='application/json', status=status)
def json_success(data={}):
def json_success(data=None):
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)
def json_unhandled_exception():