Mercurial > hg
comparison contrib/check-code.py @ 13074:637627f31c74
check-code: check for gratuitous whitespace after Python keywords
author | Thomas Arendsen Hein <thomas@jtah.de> |
---|---|
date | Fri, 03 Dec 2010 11:23:38 +0100 |
parents | 3da456d0c885 |
children | a861c7155f09 |
comparison
equal
deleted
inserted
replaced
13072:8c6b7a5f38c4 | 13074:637627f31c74 |
---|---|
6 # | 6 # |
7 # This software may be used and distributed according to the terms of the | 7 # This software may be used and distributed according to the terms of the |
8 # GNU General Public License version 2 or any later version. | 8 # GNU General Public License version 2 or any later version. |
9 | 9 |
10 import re, glob, os, sys | 10 import re, glob, os, sys |
11 import keyword | |
11 import optparse | 12 import optparse |
12 | 13 |
13 def repquote(m): | 14 def repquote(m): |
14 t = re.sub(r"\w", "x", m.group('text')) | 15 t = re.sub(r"\w", "x", m.group('text')) |
15 t = re.sub(r"[^\sx]", "o", t) | 16 t = re.sub(r"[^\sx]", "o", t) |
134 (r'(?<!def)\s+(any|all|format)\(', | 135 (r'(?<!def)\s+(any|all|format)\(', |
135 "any/all/format not available in Python 2.4"), | 136 "any/all/format not available in Python 2.4"), |
136 (r'(?<!def)\s+(callable)\(', | 137 (r'(?<!def)\s+(callable)\(', |
137 "callable not available in Python 3, use hasattr(f, '__call__')"), | 138 "callable not available in Python 3, use hasattr(f, '__call__')"), |
138 (r'if\s.*\selse', "if ... else form not available in Python 2.4"), | 139 (r'if\s.*\selse', "if ... else form not available in Python 2.4"), |
140 (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist), | |
141 "gratuitous whitespace after Python keyword"), | |
139 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"), | 142 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"), |
140 # (r'\s\s=', "gratuitous whitespace before ="), | 143 # (r'\s\s=', "gratuitous whitespace before ="), |
141 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', | 144 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', |
142 "missing whitespace around operator"), | 145 "missing whitespace around operator"), |
143 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', | 146 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', |