From b210727e5ce81e059b348d216350dc0e059c8380 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Tue, 24 May 2016 19:12:55 +0530 Subject: [PATCH] Enable running tools/run-mypy on a subdirectory. Previously tools/run-mypy could not run on a subdirectory properly because run-mypy assumed exclude files to be in that subdirectory. --- tools/run-mypy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/run-mypy b/tools/run-mypy index 60d92624e6..26aa4a2fbc 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -10,7 +10,7 @@ import argparse import subprocess import six -exclude=""" +exclude = """ api/integrations/ bots/jabber_mirror_backend.py bots/zephyr_mirror_backend.py @@ -36,6 +36,9 @@ args = parser.parse_args() if args.all: exclude = [] +# find all non-excluded files in current directory +BASE_DIR = dirname(dirname(abspath(__file__))) +exclude = [os.path.join(BASE_DIR, fpath) for fpath in exclude] python_files = lister.list_files(targets=args.targets, ftypes=['py'], use_shebang=False, modified_only=args.modified, exclude=exclude) @@ -48,6 +51,7 @@ if six.PY2 and os.path.exists(MYPY_VENV_PATH): else: mypy_command = "mypy" +# run mypy if python_files: rc = subprocess.call([mypy_command, "--fast-parser", "--silent-imports", "--py2", "--check-untyped-defs"] + python_files) sys.exit(rc)