Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,9 @@ def whitespace_before_comment(logical_line, tokens):
if token_type == tokenize.COMMENT:
inline_comment = line[:start[1]].strip()
if inline_comment:
if prev_end[0] == start[0] and start[1] < prev_end[1] + 2:
contains_tab = '\t' in line[prev_end[1]: prev_end[1] + 2]
nottwo = prev_end[0] == start[0] and start[1] < prev_end[1] + 2
if contains_tab or nottwo:
yield (prev_end,
"E261 at least two spaces before inline comment")
symbol, sp, comment = text.partition(' ')
Expand Down
8 changes: 8 additions & 0 deletions testsuite/E26.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#: E261:1:5
pass # an inline comment
#: E261:1:5
pass # an inline comment
#: E261:1:5
pass # an inline comment
#: E261:1:5
pass # an inline comment
#: E262:1:12
x = x + 1 #Increment x
#: E262:1:12
x = x + 1 # Increment x
#: E262:1:12
x = x + 1 # Increment x
#: E262:1:12
x = y + 1 #: Increment x
Expand Down