summaryrefslogtreecommitdiff
path: root/pep8.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2014-04-26 21:02:05 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2014-04-26 21:02:05 +0200
commitddebc11cdde6674a767e23ccdcf390b2340ffd80 (patch)
tree8ba8712bcdde36c8b45a4ca7f795f6f8d00e36e1 /pep8.py
parenta176b77c22ef0c0263ca4f956b9b7c91ea659885 (diff)
downloadpep8-ddebc11cdde6674a767e23ccdcf390b2340ffd80.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 a254716..ac6bfed 100755
--- a/pep8.py
+++ b/pep8.py
@@ -787,6 +787,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:
@@ -797,13 +798,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