Skip to content

Commit 66d353d

Browse files
committed
Fix an incorrect "W391 blank line at EOF"
It only happens when there is a multiline string at EOF that happens to contain a blank line. Introduced by my special treatment of multiline strings.
1 parent 99b8b4d commit 66d353d

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

pep8.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ def run_check(self, check, argument_names):
12491249
arguments.append(getattr(self, name))
12501250
return check(*arguments)
12511251

1252-
def check_physical(self, line_number, line):
1252+
def check_physical(self, line):
12531253
"""
12541254
Run all physical checks on a raw input line.
12551255
"""
@@ -1258,7 +1258,7 @@ def check_physical(self, line_number, line):
12581258
result = self.run_check(check, argument_names)
12591259
if result is not None:
12601260
offset, text = result
1261-
self.report_error(line_number, offset, text, check)
1261+
self.report_error(self.line_number, offset, text, check)
12621262

12631263
def build_tokens_line(self):
12641264
"""
@@ -1358,12 +1358,12 @@ def maybe_check_physical(self, token):
13581358
# *not* check the last line: its newline is outside of the
13591359
# multiline string, so we consider it a regular physical line
13601360
# (it will be checked when we see the newline token).
1361-
line_number = token[2][0]
1361+
self.line_number = token[2][0]
13621362
for line in token[1].split('\n')[:-1]:
1363-
self.check_physical(line_number, line + '\n')
1364-
line_number += 1
1363+
self.check_physical(line + '\n')
1364+
self.line_number += 1
13651365
elif token[0] in (tokenize.NEWLINE, tokenize.NL):
1366-
self.check_physical(self.line_number, token[4])
1366+
self.check_physical(token[4])
13671367

13681368
def check_all(self, expected=None, line_offset=0):
13691369
"""

testsuite/W39no.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#: Okay
2+
'''there is nothing wrong
3+
with a multiline string at EOF
4+
5+
that happens to have a blank line in it
6+
'''

0 commit comments

Comments
 (0)