run-mypy: Add --version to check the version of mypy used.

This commit is contained in:
Greg Price 2017-09-26 14:33:21 -07:00 committed by Greg Price
parent c46755d48d
commit 9ef68d6d42
1 changed files with 14 additions and 9 deletions

View File

@ -26,6 +26,8 @@ zproject/test_settings.py
parser = argparse.ArgumentParser(description="Run mypy on files tracked by git.")
parser.add_argument('targets', nargs='*',
help="files and directories to check (default: .)")
parser.add_argument('--version', action='store_true',
help="just run mypy --version")
parser.add_argument('--quick', action='store_true',
help="pass --quick to mypy")
parser.add_argument('-m', '--modified', action='store_true',
@ -57,6 +59,18 @@ if not args.force:
print('If you really know what you are doing, use --force to run anyway.')
sys.exit(1)
# Use zulip-py3-venv's mypy if it's available.
VENV_DIR = "/srv/zulip-py3-venv"
MYPY_VENV_PATH = os.path.join(VENV_DIR, "bin", "mypy")
if os.path.exists(MYPY_VENV_PATH):
mypy_command = MYPY_VENV_PATH
print("Using mypy from", mypy_command)
else:
mypy_command = "mypy"
if args.version:
sys.exit(subprocess.call([mypy_command, "--version"]))
if args.all:
exclude = []
@ -70,15 +84,6 @@ pyi_files = set(files_dict['pyi'])
python_files = [fpath for fpath in files_dict['py']
if not fpath.endswith('.py') or fpath + 'i' not in pyi_files]
# Use zulip-py3-venv's mypy if it's available.
VENV_DIR = "/srv/zulip-py3-venv"
MYPY_VENV_PATH = os.path.join(VENV_DIR, "bin", "mypy")
if os.path.exists(MYPY_VENV_PATH):
mypy_command = MYPY_VENV_PATH
print("Using mypy from", mypy_command)
else:
mypy_command = "mypy"
extra_args = ["--check-untyped-defs",
"--follow-imports=silent",
"--scripts-are-modules",