summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ward <greg@gerg.ca>2013-11-08 15:37:14 -0500
committerGreg Ward <greg@gerg.ca>2013-11-08 16:19:26 -0500
commit66d353dd2e68197d6c168f188bfad68b6f738908 (patch)
tree64a289dde81335cb42104b07647acfda5cada6eb
parent99b8b4d9e487a17f012030b700fbf59aebd95680 (diff)
downloadpep8-66d353dd2e68197d6c168f188bfad68b6f738908.tar.gz
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.
-rwxr-xr-xpep8.py12
-rw-r--r--testsuite/W39no.py6
2 files changed, 12 insertions, 6 deletions
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
+'''