Skip to content

Commit

Permalink
Merge pull request #1234 from augustelalande/main
Browse files Browse the repository at this point in the history
E502: Fix E502 being disabled after a comment in a logical line
  • Loading branch information
asottile committed Mar 17, 2024
2 parents f64106f + 72668f6 commit acbcec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,8 @@ def explicit_line_join(logical_line, tokens):
comment = True
if start[0] != prev_start and parens and backslash and not comment:
yield backslash, "E502 the backslash is redundant between brackets"
if start[0] != prev_start:
comment = False # Reset comment flag on newline
if end[0] != prev_end:
if line.rstrip('\r\n').endswith('\\'):
backslash = (end[0], len(line.splitlines()[-1]) - 1)
Expand Down
7 changes: 7 additions & 0 deletions testing/data/E50.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
if (foo is None and bar is "e000" and \
blah == 'yeah'):
blah = 'yeahnah'
#: E502 W503 W503
y = (
2 + 2 # \
+ 3 # \
+ 4 \
+ 3
)
#
#: Okay
a = ('AAA'
Expand Down

0 comments on commit acbcec4

Please sign in to comment.