summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2013-11-07 16:36:33 +0100
committerRadomir Dopieralski <openstack@sheep.art.pl>2013-11-07 16:36:33 +0100
commitcc0a19f1c265029dcbbff8bb76cf6c9bf076fca4 (patch)
treee555254ddf1ab476347d471bf1c7c75cb3664685
parent8d658692345e6866741719595f14a144337b3b9f (diff)
downloadpep8-cc0a19f1c265029dcbbff8bb76cf6c9bf076fca4.tar.gz
Fix #240: Allow errors on empty files
The noqa check crashes when the file is empty. The soultion is to not check for noqa when the file is empty -- if it's empty, the user might not possibly put any #noqa comments in there.
-rw-r--r--CHANGES.txt1
-rwxr-xr-xpep8.py2
2 files changed, 2 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 6465cb3..413c134 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,7 @@ Changelog
1.x (unreleased)
----------------
+* Allow the checkers to report errors on empty files. (Issue #240)
* Fix ignoring too many checks when ``--select`` is used with codes
declared in a flake8 extension. (Issue #216)
diff --git a/pep8.py b/pep8.py
index e0035b3..11e9bcc 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1344,7 +1344,7 @@ class Checker(object):
for name, cls, _ in self._ast_checks:
checker = cls(tree, self.filename)
for lineno, offset, text, check in checker.run():
- if not noqa(self.lines[lineno - 1]):
+ if not self.lines or not noqa(self.lines[lineno - 1]):
self.report_error(lineno, offset, text, check)
def generate_tokens(self):