mirror of https://github.com/zulip/zulip.git
tools/run-mypy: Use mypy from zulip-py3-venv if present.
This commit is contained in:
parent
c80f699321
commit
3601b9eda9
|
@ -3,10 +3,12 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
from os.path import dirname, abspath
|
||||
import sys
|
||||
import lister
|
||||
import argparse
|
||||
import subprocess
|
||||
import six
|
||||
|
||||
exclude="""
|
||||
api/integrations/
|
||||
|
@ -45,13 +47,24 @@ if args.all:
|
|||
python_files = lister.list_files(targets=args.targets, ftypes=['py'], use_shebang=False,
|
||||
modified_only=args.modified, exclude=exclude)
|
||||
|
||||
# Use zulip-py3-venv's mypy if it's available and we're on python 2
|
||||
PY3_VENV_DIR = "/srv/zulip-py3-venv"
|
||||
MYPY_VENV_PATH = os.path.join(PY3_VENV_DIR, "bin", "mypy")
|
||||
if six.PY2 and os.path.exists(MYPY_VENV_PATH):
|
||||
mypy_command = MYPY_VENV_PATH
|
||||
print("Using mypy from", mypy_command)
|
||||
else:
|
||||
mypy_command = "mypy"
|
||||
|
||||
if python_files:
|
||||
rc = subprocess.call(["mypy", "--silent", "--py2", "--check-untyped-defs"] + python_files)
|
||||
rc = subprocess.call([mypy_command, "--silent", "--py2", "--check-untyped-defs"] + python_files)
|
||||
if not rc:
|
||||
print("The mypy static type checker for python detected no errors!")
|
||||
else:
|
||||
print("\nThe mypy static type checker for Python threw some errors,")
|
||||
print("which indicates a bug in your code or incorrect type annotations.")
|
||||
print("Please see docs/mypy.md for details on how Zulip is using mypy")
|
||||
print("to find bugs and how to debug the issue.")
|
||||
sys.exit(rc)
|
||||
else:
|
||||
print("There are no files to run mypy on.")
|
||||
|
|
Loading…
Reference in New Issue