mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 05:54:17 +00:00
Exit non-zero if something goes wrong during a run
If we handle an exception, or early exit, or really anything, we should exit non-zero (and we used to). This was a minor oversight. Closes #209 Closes #248
This commit is contained in:
parent
eff9f607bb
commit
c81a403fef
3 changed files with 79 additions and 2 deletions
|
|
@ -102,6 +102,9 @@ class Application(object):
|
|||
#: The total number of errors before accounting for ignored errors and
|
||||
#: lines.
|
||||
self.total_result_count = 0
|
||||
#: Whether or not something catastrophic happened and we should exit
|
||||
#: with a non-zero status code
|
||||
self.catastrophic_failure = False
|
||||
|
||||
#: Whether the program is processing a diff or not
|
||||
self.running_against_diff = False
|
||||
|
|
@ -119,7 +122,8 @@ class Application(object):
|
|||
print(self.result_count)
|
||||
|
||||
if not self.options.exit_zero:
|
||||
raise SystemExit(self.result_count > 0)
|
||||
raise SystemExit((self.result_count > 0) or
|
||||
self.catastrophic_failure)
|
||||
|
||||
def find_plugins(self):
|
||||
# type: () -> NoneType
|
||||
|
|
@ -321,5 +325,7 @@ class Application(object):
|
|||
LOG.critical('Caught keyboard interrupt from user')
|
||||
LOG.exception(exc)
|
||||
self.file_checker_manager._force_cleanup()
|
||||
self.catastrophic_failure = True
|
||||
except exceptions.EarlyQuit:
|
||||
self.catastrophic_failure = True
|
||||
print('... stopped while processing files')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue