comparison contrib/check-code.py @ 14763:b071cd58af50 stable

check-code: fix class style checking (with tests) - old-style classes were only checked for one-letter class names - add check for new-style classes with empty parent class, because this is not available in Python 2.4
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 29 Jun 2011 13:45:51 +0200
parents 6c7283faa967
children 0407b7613e99
comparison
equal deleted inserted replaced
14762:6beb26747430 14763:b071cd58af50
126 (r'(\S\s+|^\s+)\n', "trailing whitespace"), 126 (r'(\S\s+|^\s+)\n', "trailing whitespace"),
127 # (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"), 127 # (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"),
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"),
135 # (r'class\s[A-Z][^\(]*\((?!Exception)', 137 # (r'class\s[A-Z][^\(]*\((?!Exception)',
136 # "don't capitalize non-exception classes"), 138 # "don't capitalize non-exception classes"),