From 1feeec96f923a813d5ecd0d08ee200f089c8753b Mon Sep 17 00:00:00 2001 From: Steven Kryskalla Date: Tue, 21 Feb 2012 17:02:53 -0800 Subject: [PATCH] Add a flag for exiting with status code 0, even when there are warnings This might be useful e.g. in a build system where exiting with status code > 0 always means the build failed. In that case, you still want to signify that flake8 itself ran without problems, even when there are warnings. --- flake8/pep8.py | 3 +++ flake8/run.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/flake8/pep8.py b/flake8/pep8.py index 766302b..80cbfe6 100644 --- a/flake8/pep8.py +++ b/flake8/pep8.py @@ -1287,6 +1287,9 @@ def process_options(arglist=None): help="exclude files or directories which match these " "comma separated patterns (default: %s)" % DEFAULT_EXCLUDE) + parser.add_option('--exit-zero', action='store_true', + help="use exit code 0 (success), even if there are " + "warnings") parser.add_option('--filename', metavar='patterns', default='*.py', help="when parsing directories, only check filenames " "matching these comma separated patterns (default: " diff --git a/flake8/run.py b/flake8/run.py index 8683e50..7900e56 100644 --- a/flake8/run.py +++ b/flake8/run.py @@ -59,6 +59,9 @@ def main(): else: stdin = sys.stdin.read() warnings += check_code(stdin, complexity) + + if options.exit_zero: + raise SystemExit(0) raise SystemExit(warnings > 0)