From 064f986d9a42201442e5d9cf2186afdcaa106bbf Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Wed, 13 Feb 2013 09:51:32 -0500 Subject: [PATCH] Fixes #69 Note to self: I also have to make sure the VCS hooks work with the new pyflakes API. --- flake8/main.py | 4 +++- flake8/util.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flake8/main.py b/flake8/main.py index 3a763a9..66ee41c 100644 --- a/flake8/main.py +++ b/flake8/main.py @@ -65,13 +65,14 @@ def main(): if opts.exit_zero: raise SystemExit(0) - raise SystemExit(warnings) + raise SystemExit(warnings > 0) def check_file(path, ignore=(), complexity=-1, reporter=None): if pep8style.excluded(path): return 0 warnings = pyflakes.api.checkPath(path, reporter) + warnings -= reporter.ignored_warnings warnings += pep8style.input_file(path) if complexity > -1: warnings += mccabe.get_module_complexity(path, complexity) @@ -80,6 +81,7 @@ def check_file(path, ignore=(), complexity=-1, reporter=None): def check_code(code, ignore=(), complexity=-1, reporter=None): warnings = pyflakes.api.check(code, '', reporter) + warnings -= reporter.ignored_warnings warnings += pep8style.input_file('-', lines=code.split('\n')) if complexity > -1: warnings += mccabe.get_code_complexity(code, complexity) diff --git a/flake8/util.py b/flake8/util.py index 6083e5c..6412a6d 100644 --- a/flake8/util.py +++ b/flake8/util.py @@ -137,12 +137,14 @@ class Flake8Reporter(reporter.Reporter): def __init__(self, ignore=None): super(Flake8Reporter, self).__init__(sys.stdout, sys.stderr) self.ignore = ignore or [] + self.ignored_warnings = 0 def flake(self, message): classes = [error_mapping[i] for i in self.ignore if i in error_mapping] if (any(isinstance(message, c) for c in classes) or skip_warning(message)): + self.ignored_warnings += 1 return m = self.to_str(message) i = m.rfind(':') + 1