lint: Catch exit(1) in management commands.

Using sys.exit(1) in a management command makes it impossible
to unit test the code in question.  The correct approach to
do the same thing in Django management commands is to raise
CommandError.
This commit is contained in:
Vishnu Ks
2019-05-16 17:50:36 +05:30
committed by Tim Abbott
parent 5f50c4d799
commit 56259c7acd

View File

@@ -673,6 +673,10 @@ def build_custom_checkers(by_lang):
]),
'description': "Now that we're a Python 3 only codebase, we don't need to use typing.Text. Please use str instead.",
},
{'pattern': 'exit[(]1[)]',
'include_only': set(["/management/commands/"]),
'description': 'Raise CommandError to exit with failure in management commands',
},
]) + whitespace_rules + comma_whitespace_rule
bash_rules = cast(RuleList, [
{'pattern': '#!.*sh [-xe]',