##// END OF EJS Templates
check-code: fix class style checking (with tests)...
Thomas Arendsen Hein -
r14763:b071cd58 stable
parent child Browse files
Show More
@@ -128,7 +128,9 b' pypats = ['
128 # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"),
128 # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"),
129 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+',
129 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+',
130 "linebreak after :"),
130 "linebreak after :"),
131 (r'class\s[^(]:', "old-style class, use class foo(object)"),
131 (r'class\s[^( ]+:', "old-style class, use class foo(object)"),
132 (r'class\s[^( ]+\(\):',
133 "class foo() not available in Python 2.4, use class foo(object)"),
132 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
134 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
133 "Python keyword is not a function"),
135 "Python keyword is not a function"),
134 (r',]', "unneeded trailing ',' in list"),
136 (r',]', "unneeded trailing ',' in list"),
@@ -27,8 +27,21 b''
27 > def any(x):
27 > def any(x):
28 > pass
28 > pass
29 > EOF
29 > EOF
30 $ cat > classstyle.py <<EOF
31 > class newstyle_class(object):
32 > pass
33 >
34 > class oldstyle_class:
35 > pass
36 >
37 > class empty():
38 > pass
39 >
40 > no_class = 1:
41 > pass
42 > EOF
30 $ check_code="$TESTDIR"/../contrib/check-code.py
43 $ check_code="$TESTDIR"/../contrib/check-code.py
31 $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py
44 $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py ./classstyle.py
32 ./wrong.py:1:
45 ./wrong.py:1:
33 > def toto( arg1, arg2):
46 > def toto( arg1, arg2):
34 gratuitous whitespace in () or []
47 gratuitous whitespace in () or []
@@ -51,6 +64,12 b''
51 ./non-py24.py:4:
64 ./non-py24.py:4:
52 > y = format(x)
65 > y = format(x)
53 any/all/format not available in Python 2.4
66 any/all/format not available in Python 2.4
67 ./classstyle.py:4:
68 > class oldstyle_class:
69 old-style class, use class foo(object)
70 ./classstyle.py:7:
71 > class empty():
72 class foo() not available in Python 2.4, use class foo(object)
54 [1]
73 [1]
55
74
56 $ cat > is-op.py <<EOF
75 $ cat > is-op.py <<EOF
General Comments 0
You need to be logged in to leave comments. Login now