mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	lint: Generalize --skip arg and move logic to zulint/command.
This commit is contained in:
		
							
								
								
									
										16
									
								
								tools/lint
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								tools/lint
									
									
									
									
									
								
							@@ -90,15 +90,11 @@ def run():
 | 
			
		||||
    linter_config.external_linter('templates', ['tools/check-templates'], ['handlebars', 'html'])
 | 
			
		||||
    linter_config.external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml'])
 | 
			
		||||
    linter_config.external_linter('shellcheck', ['shellcheck', '-x'], ['sh'])
 | 
			
		||||
    if 'mypy' not in args.skip:
 | 
			
		||||
        command = ['tools/run-mypy']
 | 
			
		||||
        if args.force:
 | 
			
		||||
            command.append('--force')
 | 
			
		||||
        linter_config.external_linter('mypy', command, ['py'], pass_targets=False)
 | 
			
		||||
 | 
			
		||||
    # Disabled check for imperative mood until it is stabilized
 | 
			
		||||
    if 'gitlint' not in args.skip:
 | 
			
		||||
        linter_config.external_linter('gitlint', ['tools/commit-message-lint'])
 | 
			
		||||
    command = ['tools/run-mypy']
 | 
			
		||||
    if args.force:
 | 
			
		||||
        command.append('--force')
 | 
			
		||||
    linter_config.external_linter('mypy', command, ['py'], pass_targets=False)
 | 
			
		||||
    linter_config.external_linter('gitlint', ['tools/commit-message-lint'])
 | 
			
		||||
 | 
			
		||||
    @linter_config.lint
 | 
			
		||||
    def custom_py():
 | 
			
		||||
@@ -135,7 +131,7 @@ def run():
 | 
			
		||||
        failed = check_pep8(list(python_part2))
 | 
			
		||||
        return 1 if failed else 0
 | 
			
		||||
 | 
			
		||||
    linter_config.do_lint(only=args.only)
 | 
			
		||||
    linter_config.do_lint(skip=args.skip, only=args.only)
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    run()
 | 
			
		||||
 
 | 
			
		||||
@@ -111,10 +111,13 @@ class LinterConfig:
 | 
			
		||||
 | 
			
		||||
        self.lint_functions[name] = run_linter
 | 
			
		||||
 | 
			
		||||
    def do_lint(self, only=[]):
 | 
			
		||||
        # type: (List[str]) -> None
 | 
			
		||||
    def do_lint(self, only=[], skip=[]):
 | 
			
		||||
        # type: (List[str], List[str]) -> None
 | 
			
		||||
        assert not only or not skip, "Only one of --only or --skip can be used at once."
 | 
			
		||||
        if only:
 | 
			
		||||
            self.lint_functions = {linter: self.lint_functions[linter] for linter in only}
 | 
			
		||||
        for linter in skip:
 | 
			
		||||
            del self.lint_functions[linter]
 | 
			
		||||
 | 
			
		||||
        failed = run_parallel(self.lint_functions)
 | 
			
		||||
        sys.exit(1 if failed else 0)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user