Mercurial > public > mercurial-scm > hg
comparison contrib/check-code.py @ 31476:413b44003462
py3: add __bool__ to every class defining __nonzero__
__nonzero__ was renamed to __bool__ in Python 3. This patch simply
aliases __bool__ to __nonzero__ for every class implementing
__nonzero__.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 13 Mar 2017 12:40:14 -0700 |
parents | 455677a7667f |
children | c0c4e14ee597 |
comparison
equal
deleted
inserted
replaced
31475:1b9b00aca8a3 | 31476:413b44003462 |
---|---|
316 (r'^\s*except\s*:', "naked except clause", r'#.*re-raises'), | 316 (r'^\s*except\s*:', "naked except clause", r'#.*re-raises'), |
317 (r'^\s*except\s([^\(,]+|\([^\)]+\))\s*,', | 317 (r'^\s*except\s([^\(,]+|\([^\)]+\))\s*,', |
318 'legacy exception syntax; use "as" instead of ","'), | 318 'legacy exception syntax; use "as" instead of ","'), |
319 (r':\n( )*( ){1,3}[^ ]', "must indent 4 spaces"), | 319 (r':\n( )*( ){1,3}[^ ]', "must indent 4 spaces"), |
320 (r'release\(.*wlock, .*lock\)', "wrong lock release order"), | 320 (r'release\(.*wlock, .*lock\)', "wrong lock release order"), |
321 (r'\b__bool__\b', "__bool__ should be __nonzero__ in Python 2"), | 321 (r'\bdef\s+__bool__\b', "__bool__ should be __nonzero__ in Python 2"), |
322 (r'os\.path\.join\(.*, *(""|\'\')\)', | 322 (r'os\.path\.join\(.*, *(""|\'\')\)', |
323 "use pathutil.normasprefix(path) instead of os.path.join(path, '')"), | 323 "use pathutil.normasprefix(path) instead of os.path.join(path, '')"), |
324 (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'), | 324 (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'), |
325 # XXX only catch mutable arguments on the first line of the definition | 325 # XXX only catch mutable arguments on the first line of the definition |
326 (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"), | 326 (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"), |