zulint: Extract common linter argument parsing logic.

The remaining code is Zulip-specific business logic.
This commit is contained in:
Tim Abbott 2018-08-04 14:18:50 -07:00
parent 1fcc2a6ea4
commit acf8ec492d
3 changed files with 21 additions and 10 deletions

View File

@ -62,7 +62,7 @@ ignore_missing_imports = True
[mypy-linter_lib.printer]
ignore_missing_imports = True
[mypy-zulint,zulint.lister,zulint.lister.*]
[mypy-zulint,zulint.*,zulint.lister.*]
ignore_missing_imports = True

View File

@ -14,6 +14,7 @@ from lib import sanity_check
sanity_check.check_venv(__file__)
from zulint import lister
from zulint.command import add_default_linter_arguments
from typing import cast, Callable, Dict, Iterator, List
@ -50,15 +51,6 @@ def run():
parser.add_argument('--no-gitlint',
action='store_true',
help='Disable gitlint')
parser.add_argument('--modified', '-m',
action='store_true',
help='Only check modified files')
parser.add_argument('--verbose', '-v',
action='store_true',
help='Print verbose timing output')
parser.add_argument('targets',
nargs='*',
help='Specify directories to check')
limited_tests_group = parser.add_mutually_exclusive_group()
limited_tests_group.add_argument('--frontend',
action='store_true',
@ -66,6 +58,7 @@ def run():
limited_tests_group.add_argument('--backend',
action='store_true',
help='Only check files relevant to backend')
add_default_linter_arguments(parser)
args = parser.parse_args()
tools_dir = os.path.dirname(os.path.abspath(__file__))

18
tools/zulint/command.py Normal file
View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
import argparse
def add_default_linter_arguments(parser):
# type: (argparse.ArgumentParser) -> None
parser.add_argument('--modified', '-m',
action='store_true',
help='Only check modified files')
parser.add_argument('--verbose', '-v',
action='store_true',
help='Print verbose timing output')
parser.add_argument('targets',
nargs='*',
help='Specify directories to check')