lint: Pass args instead of passing individual attributes to do_lint.

Pass the args to linter_config.do_lint.
This commit is contained in:
Aman Agrawal
2019-06-20 22:33:59 +05:30
committed by Tim Abbott
parent b2b49089fd
commit b6d4438726
2 changed files with 8 additions and 8 deletions

View File

@@ -125,7 +125,7 @@ def run():
# type: () -> int # type: () -> int
failed = check_pep8(list(python_part2)) failed = check_pep8(list(python_part2))
return 1 if failed else 0 return 1 if failed else 0
linter_config.do_lint(skip=args.skip, only=args.only, only_list=args.list) linter_config.do_lint(args)
if __name__ == '__main__': if __name__ == '__main__':
run() run()

View File

@@ -114,14 +114,14 @@ class LinterConfig:
self.lint_functions[name] = run_linter self.lint_functions[name] = run_linter
def do_lint(self, only=[], skip=[], only_list=False): def do_lint(self, args):
# type: (List[str], List[str], bool) -> None # type: (argparse.Namespace) -> None
assert not only or not skip, "Only one of --only or --skip can be used at once." assert not args.only or not args.skip, "Only one of --only or --skip can be used at once."
if only: if args.only:
self.lint_functions = {linter: self.lint_functions[linter] for linter in only} self.lint_functions = {linter: self.lint_functions[linter] for linter in args.only}
for linter in skip: for linter in args.skip:
del self.lint_functions[linter] del self.lint_functions[linter]
if only_list: if args.list:
print("\n".join(self.lint_functions.keys())) print("\n".join(self.lint_functions.keys()))
sys.exit() sys.exit()