diff options
Diffstat (limited to 'pep8.py')
-rwxr-xr-x | pep8.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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 |