fix AttributeError when catatstrophic failure is triggered

This commit is contained in:
Anthony Sottile 2021-12-24 16:38:17 -05:00
parent f7a86ca04b
commit a7be5e798b
2 changed files with 19 additions and 6 deletions

View file

@ -115,11 +115,13 @@ class Application:
def exit_code(self) -> int:
"""Return the program exit code."""
if self.catastrophic_failure:
return 1
assert self.options is not None
if self.options.exit_zero:
return int(self.catastrophic_failure)
return 0
else:
return int((self.result_count > 0) or self.catastrophic_failure)
return int(self.result_count > 0)
def find_plugins(
self,
@ -391,7 +393,7 @@ class Application:
except exceptions.EarlyQuit:
self.catastrophic_failure = True
print("... stopped while processing files")
assert self.options is not None
if self.options.count:
print(self.result_count)
else:
assert self.options is not None
if self.options.count:
print(self.result_count)