diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-04-26 21:02:05 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-04-26 21:02:05 +0200 |
commit | ddebc11cdde6674a767e23ccdcf390b2340ffd80 (patch) | |
tree | 8ba8712bcdde36c8b45a4ca7f795f6f8d00e36e1 /pep8.py | |
parent | a176b77c22ef0c0263ca4f956b9b7c91ea659885 (diff) | |
download | pep8-ddebc11cdde6674a767e23ccdcf390b2340ffd80.tar.gz |
Report E266 instead of E265 when the block common starts with multiple #; issue #270
Diffstat (limited to 'pep8.py')
-rwxr-xr-x | pep8.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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 |