From 72668f67e94d58e69914dd4b139907956ef79575 Mon Sep 17 00:00:00 2001 From: augustelalande Date: Fri, 8 Mar 2024 15:42:38 -0500 Subject: [PATCH] fix E502 being disabled after a comment --- pycodestyle.py | 2 ++ testing/data/E50.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/pycodestyle.py b/pycodestyle.py index 9adbb6b1..6443a42a 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -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) diff --git a/testing/data/E50.py b/testing/data/E50.py index 6ab50c88..4870fcc2 100644 --- a/testing/data/E50.py +++ b/testing/data/E50.py @@ -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'