diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -128,7 +128,9 @@ pypats = [ # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"), (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+', "linebreak after :"), - (r'class\s[^(]:', "old-style class, use class foo(object)"), + (r'class\s[^( ]+:', "old-style class, use class foo(object)"), + (r'class\s[^( ]+\(\):', + "class foo() not available in Python 2.4, use class foo(object)"), (r'\b(%s)\(' % '|'.join(keyword.kwlist), "Python keyword is not a function"), (r',]', "unneeded trailing ',' in list"), diff --git a/tests/test-check-code.t b/tests/test-check-code.t --- a/tests/test-check-code.t +++ b/tests/test-check-code.t @@ -27,8 +27,21 @@ > def any(x): > pass > EOF + $ cat > classstyle.py < class newstyle_class(object): + > pass + > + > class oldstyle_class: + > pass + > + > class empty(): + > pass + > + > no_class = 1: + > pass + > EOF $ check_code="$TESTDIR"/../contrib/check-code.py - $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py + $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py ./classstyle.py ./wrong.py:1: > def toto( arg1, arg2): gratuitous whitespace in () or [] @@ -51,6 +64,12 @@ ./non-py24.py:4: > y = format(x) any/all/format not available in Python 2.4 + ./classstyle.py:4: + > class oldstyle_class: + old-style class, use class foo(object) + ./classstyle.py:7: + > class empty(): + class foo() not available in Python 2.4, use class foo(object) [1] $ cat > is-op.py <