check-code: check for gratuitous whitespace after Python keywords
authorThomas Arendsen Hein <thomas@jtah.de>
Fri, 03 Dec 2010 11:23:38 +0100
changeset 13074 637627f31c74
parent 13072 8c6b7a5f38c4
child 13075 d73c3034deee
check-code: check for gratuitous whitespace after Python keywords
contrib/check-code.py
--- a/contrib/check-code.py	Wed Dec 01 18:47:40 2010 -0600
+++ b/contrib/check-code.py	Fri Dec 03 11:23:38 2010 +0100
@@ -8,6 +8,7 @@
 # GNU General Public License version 2 or any later version.
 
 import re, glob, os, sys
+import keyword
 import optparse
 
 def repquote(m):
@@ -136,6 +137,8 @@
     (r'(?<!def)\s+(callable)\(',
      "callable not available in Python 3, use hasattr(f, '__call__')"),
     (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
+    (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist),
+     "gratuitous whitespace after Python keyword"),
     (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"),
 #    (r'\s\s=', "gratuitous whitespace before ="),
     (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',