diff options
author | Radomir Dopieralski <openstack@sheep.art.pl> | 2013-11-07 16:36:33 +0100 |
---|---|---|
committer | Radomir Dopieralski <openstack@sheep.art.pl> | 2013-11-07 16:36:33 +0100 |
commit | cc0a19f1c265029dcbbff8bb76cf6c9bf076fca4 (patch) | |
tree | e555254ddf1ab476347d471bf1c7c75cb3664685 | |
parent | 8d658692345e6866741719595f14a144337b3b9f (diff) | |
download | pep8-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.txt | 1 | ||||
-rwxr-xr-x | pep8.py | 2 |
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) @@ -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): |