comparison contrib/check-code.py @ 48945:55d132525155

check-code: remove ban on old-style classes In Python 3, `class foo:` is equivalent to `class foo(object):`. So we can allow the former form now. Differential Revision: https://phab.mercurial-scm.org/D12351
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 21 Feb 2022 13:03:43 -0700
parents 82f1c46cce5c
children 642e31cb55f0
comparison
equal deleted inserted replaced
48944:fe3303436b79 48945:55d132525155
339 (r'[^\n]\Z', "no trailing newline"), 339 (r'[^\n]\Z', "no trailing newline"),
340 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"), 340 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
341 ( 341 (
342 r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+', 342 r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
343 "linebreak after :", 343 "linebreak after :",
344 ),
345 (
346 r'class\s[^( \n]+:',
347 "old-style class, use class foo(object)",
348 r'#.*old-style',
349 ),
350 (
351 r'class\s[^( \n]+\(\):',
352 "class foo() creates old style object, use class foo(object)",
353 r'#.*old-style',
354 ), 344 ),
355 ( 345 (
356 r'\b(%s)\(' 346 r'\b(%s)\('
357 % '|'.join(k for k in keyword.kwlist if k not in ('print', 'exec')), 347 % '|'.join(k for k in keyword.kwlist if k not in ('print', 'exec')),
358 "Python keyword is not a function", 348 "Python keyword is not a function",