comparison contrib/check-code.py @ 13076:a861c7155f09

check-code: single check for Python keywords used as a function This replaces the specific checks for del/and/or/not/except and additionally checks other Python keywords.
author Thomas Arendsen Hein <thomas@jtah.de>
date Fri, 03 Dec 2010 12:04:31 +0100
parents 637627f31c74
children 07d08c130892
comparison
equal deleted inserted replaced
13075:d73c3034deee 13076:a861c7155f09
117 # (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"), 117 # (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"),
118 # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"), 118 # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"),
119 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+', 119 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+',
120 "linebreak after :"), 120 "linebreak after :"),
121 (r'class\s[^(]:', "old-style class, use class foo(object)"), 121 (r'class\s[^(]:', "old-style class, use class foo(object)"),
122 (r'^\s+del\(', "del isn't a function"), 122 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
123 (r'\band\(', "and isn't a function"), 123 "Python keyword is not a function"),
124 (r'\bor\(', "or isn't a function"),
125 (r'\bnot\(', "not isn't a function"),
126 (r'^\s+except\(', "except isn't a function"),
127 (r',]', "unneeded trailing ',' in list"), 124 (r',]', "unneeded trailing ',' in list"),
128 # (r'class\s[A-Z][^\(]*\((?!Exception)', 125 # (r'class\s[A-Z][^\(]*\((?!Exception)',
129 # "don't capitalize non-exception classes"), 126 # "don't capitalize non-exception classes"),
130 # (r'in range\(', "use xrange"), 127 # (r'in range\(', "use xrange"),
131 # (r'^\s*print\s+', "avoid using print in core and extensions"), 128 # (r'^\s*print\s+', "avoid using print in core and extensions"),