summaryrefslogtreecommitdiff
path: root/pep8.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2014-05-29 19:33:09 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2014-05-29 19:33:09 +0200
commit999e3357c73a48fea6df8a772435af696b3f01c0 (patch)
tree9c2ee84afa40d828b5466496acfa57f6881a2bbf /pep8.py
parent3fbadb7007436c029a3ede4c057ce43171dcd617 (diff)
parentd1c33daa99c1325c16cba857248134008328fc8a (diff)
downloadpep8-999e3357c73a48fea6df8a772435af696b3f01c0.tar.gz
Report E266 instead of E265 when the block common starts with multiple #; issue #270
Diffstat (limited to 'pep8.py')
-rwxr-xr-xpep8.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/pep8.py b/pep8.py
index fbb2526..b64dfda 100755
--- a/pep8.py
+++ b/pep8.py
@@ -792,6 +792,7 @@ def whitespace_before_comment(logical_line, tokens):
E262: x = x + 1 #Increment x
E262: x = x + 1 # Increment x
E265: #Block comment
+ E266: ### Block comment
"""
prev_end = (0, 0)
for token_type, text, start, end, line in tokens:
@@ -802,13 +803,15 @@ def whitespace_before_comment(logical_line, tokens):
yield (prev_end,
"E261 at least two spaces before inline comment")
symbol, sp, comment = text.partition(' ')
- bad_prefix = symbol not in ('#', '#:')
+ bad_prefix = symbol not in '#:' and (symbol.lstrip('#')[:1] or '#')
if inline_comment:
- if bad_prefix or comment[:1].isspace():
+ if bad_prefix or comment[:1] in WHITESPACE:
yield start, "E262 inline comment should start with '# '"
- elif bad_prefix:
- if text.rstrip('#') and (start[0] > 1 or symbol[1] != '!'):
+ elif bad_prefix and (bad_prefix != '!' or start[0] > 1):
+ if bad_prefix != '#':
yield start, "E265 block comment should start with '# '"
+ elif comment:
+ yield start, "E266 too many leading '#' for block comment"
elif token_type != tokenize.NL:
prev_end = end