# HG changeset patch # User Pierre-Yves David # Date 2015-09-24 07:34:15 # Node ID b80b2ee71a08d00ec4008f3131bdf3c72e4ec2ba # Parent e9a35411bbbcf7c09ab002fca424ce982d8b3dc5 check-code: forbid mutable value for default argument default value are common to all call. Using mutable value is a classical source of bug in Python. We forbid it. The regexp (Courtesy of Matt Mackall) is only catching such value on the first line of a definition, but that will be good enough for now. diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -291,6 +291,8 @@ pypats = [ (r'os\.path\.join\(.*, *(""|\'\')\)', "use pathutil.normasprefix(path) instead of os.path.join(path, '')"), (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'), + # XXX only catch mutable arguments on the first line of the definition + (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"), ], # warnings [