Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E502: Fix E502 being disabled after a comment in a logical line #1234

Merged
merged 1 commit into from
Mar 17, 2024
Merged
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
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
Loading