Skip to content

Commit acbcec4

Browse files
authored
Merge pull request #1234 from augustelalande/main
E502: Fix E502 being disabled after a comment in a logical line
2 parents f64106f + 72668f6 commit acbcec4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pycodestyle.py

+2
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,8 @@ def explicit_line_join(logical_line, tokens):
12691269
comment = True
12701270
if start[0] != prev_start and parens and backslash and not comment:
12711271
yield backslash, "E502 the backslash is redundant between brackets"
1272+
if start[0] != prev_start:
1273+
comment = False # Reset comment flag on newline
12721274
if end[0] != prev_end:
12731275
if line.rstrip('\r\n').endswith('\\'):
12741276
backslash = (end[0], len(line.splitlines()[-1]) - 1)

testing/data/E50.py

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
if (foo is None and bar is "e000" and \
2626
blah == 'yeah'):
2727
blah = 'yeahnah'
28+
#: E502 W503 W503
29+
y = (
30+
2 + 2 # \
31+
+ 3 # \
32+
+ 4 \
33+
+ 3
34+
)
2835
#
2936
#: Okay
3037
a = ('AAA'

0 commit comments

Comments
 (0)