mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	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:
		@@ -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]',
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user