diff options
-rw-r--r-- | CONTRIBUTORS.txt | 1 | ||||
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | pylint/lint.py | 11 | ||||
-rw-r--r-- | pylint/test/test_self.py | 6 |
4 files changed, 23 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index a720347ea..40f0deb42 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -161,3 +161,4 @@ Order doesn't matter (not that much, at least ;) * Tobias Hernstig: contributor +* Jason Owen: contributor @@ -17,6 +17,12 @@ Release date: |TBA| Close #2186 + * Add `--exit-zero` option for continuous integration scripts to more + easily call Pylint in environments that abort when a program returns a + non-zero (error) status code. + + Close #2042 + What's New in Pylint 1.9.2? =========================== diff --git a/pylint/lint.py b/pylint/lint.py index be7fdaa97..1c424ea1b 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -417,6 +417,12 @@ class PyLinter(config.OptionsManagerMixIn, 'help': ('When enabled, pylint would attempt to guess common ' 'misconfiguration and emit user-friendly hints instead ' 'of false-positive error messages')}), + + ('exit-zero', + {'action': 'store_true', + 'help': ('Always return a 0 (non-error) status code, even if ' + 'lint errors are found. This is primarily useful in ' + 'continuous integration scripts.')}), ) option_groups = ( @@ -1347,7 +1353,10 @@ group are mutually exclusive.'), linter.check(args) linter.generate_reports() if exit: - sys.exit(self.linter.msg_status) + if linter.config.exit_zero: + sys.exit(0) + else: + sys.exit(self.linter.msg_status) def cb_set_rcfile(self, name, value): """callback for option preprocessing (i.e. before option parsing)""" diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py index b77988105..481d76108 100644 --- a/pylint/test/test_self.py +++ b/pylint/test/test_self.py @@ -145,6 +145,12 @@ class TestRunTC(object): def test_w0704_ignored(self): self._runtest([join(HERE, 'input', 'ignore_except_pass_by_default.py')], code=0) + def test_exit_zero(self): + self._runtest([ + '--exit-zero', + join(HERE, 'regrtest_data', 'syntax_error.py') + ], code=0) + def test_generate_config_option(self): self._runtest(['--generate-rcfile'], code=0) |