From 66d353dd2e68197d6c168f188bfad68b6f738908 Mon Sep 17 00:00:00 2001 From: Greg Ward Date: Fri, 8 Nov 2013 15:37:14 -0500 Subject: 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. --- pep8.py | 12 ++++++------ testsuite/W39no.py | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 testsuite/W39no.py diff --git a/pep8.py b/pep8.py index e2ffbbc..ce3feb0 100755 --- a/pep8.py +++ b/pep8.py @@ -1249,7 +1249,7 @@ class Checker(object): arguments.append(getattr(self, name)) return check(*arguments) - def check_physical(self, line_number, line): + def check_physical(self, line): """ Run all physical checks on a raw input line. """ @@ -1258,7 +1258,7 @@ class Checker(object): result = self.run_check(check, argument_names) if result is not None: offset, text = result - self.report_error(line_number, offset, text, check) + self.report_error(self.line_number, offset, text, check) def build_tokens_line(self): """ @@ -1358,12 +1358,12 @@ class Checker(object): # *not* check the last line: its newline is outside of the # multiline string, so we consider it a regular physical line # (it will be checked when we see the newline token). - line_number = token[2][0] + self.line_number = token[2][0] for line in token[1].split('\n')[:-1]: - self.check_physical(line_number, line + '\n') - line_number += 1 + self.check_physical(line + '\n') + self.line_number += 1 elif token[0] in (tokenize.NEWLINE, tokenize.NL): - self.check_physical(self.line_number, token[4]) + self.check_physical(token[4]) def check_all(self, expected=None, line_offset=0): """ diff --git a/testsuite/W39no.py b/testsuite/W39no.py new file mode 100644 index 0000000..2948b82 --- /dev/null +++ b/testsuite/W39no.py @@ -0,0 +1,6 @@ +#: Okay +'''there is nothing wrong +with a multiline string at EOF + +that happens to have a blank line in it +''' -- cgit v1.2.1