mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
lint: Add --only agr to run only the specified linters.
This commit is contained in:
@@ -135,7 +135,7 @@ def run():
|
||||
failed = check_pep8(list(python_part2))
|
||||
return 1 if failed else 0
|
||||
|
||||
linter_config.do_lint()
|
||||
linter_config.do_lint(only=args.only)
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
@@ -30,6 +30,10 @@ def add_default_linter_arguments(parser):
|
||||
default=[],
|
||||
type=split_arg_into_list,
|
||||
help='Specify linters to skip, eg: --skip=mypy,gitlint')
|
||||
parser.add_argument('--only',
|
||||
default=[],
|
||||
type=split_arg_into_list,
|
||||
help='Specify linters to run, eg: --only=mypy,gitlint')
|
||||
|
||||
def split_arg_into_list(arg):
|
||||
# type: (str) -> List[str]
|
||||
@@ -107,7 +111,10 @@ class LinterConfig:
|
||||
|
||||
self.lint_functions[name] = run_linter
|
||||
|
||||
def do_lint(self):
|
||||
# type: () -> None
|
||||
def do_lint(self, only=[]):
|
||||
# type: (List[str]) -> None
|
||||
if only:
|
||||
self.lint_functions = {linter: self.lint_functions[linter] for linter in only}
|
||||
|
||||
failed = run_parallel(self.lint_functions)
|
||||
sys.exit(1 if failed else 0)
|
||||
|
||||
Reference in New Issue
Block a user