Merge pull request #2988 from merriam/merriam_42

Add additional checking in comments for spaces after punctuation.
This commit is contained in:
dessant 2015-02-03 03:42:52 +02:00
commit e522733032
2 changed files with 17 additions and 4 deletions

View File

@ -1329,15 +1329,25 @@ class Checker(object):
print(('l.%s\t%s\t%s\t%r' %
(token[2][0], pos, tokenize.tok_name[token[0]], text)))
if token_type == tokenize.COMMENT or token_type == tokenize.STRING:
for sre in re.finditer("\\. ?[A-Z]", text):
for sre in re.finditer(r"[:.;,] ?[A-Za-z]", text):
pos = sre.span()[0]
part = text[:pos]
line = token[2][0] + part.count('\n')
offset = 0 if part.count('\n') > 0 else token[2][1]
col = offset + pos - part.rfind('\n') + 1
self.report_error(line, col,
'E289 Too many spaces after period. Use only one.',
check=None)
if sre.group(0)[0] == '.':
self.report_error(line, col,
'E289 Too many spaces after period. Use only one.',
check=None)
elif sre.group(0)[0] == ',':
self.report_error(line, col,
'E288 Too many spaces after comma. Use only one.',
check=None)
else:
self.report_error(line, col,
'E287 Too many spaces after punctuation. '
'Use only one.',
check=None)
if token_type == tokenize.OP:
if text in '([{':
parens += 1

View File

@ -25,6 +25,9 @@ else:
""" One with. 1 number doesn't count. lowercase doesn't. Four doesn't. """
pass
""" No we have commas, with too many spaces. a lower case sentence.
then more: issues, and, then; another issue """
pass
""" And then lots of blank lines. """