From f7cfd76403a8fde20b4b92ec3337eda3f593bdf0 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 5 Aug 2017 16:16:07 -0700 Subject: [PATCH] run-mypy: Check PROVISION_VERSION. Since new mypy versions frequently break old versions, this check is a useful way to help prevent problems where mypy output is wrong. We could probably tighten this by checking explicitly the expected mypy version from requirements.txt, but that's work. Replaces #5026. --- tools/run-mypy | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/run-mypy b/tools/run-mypy index 69c1800d26..e161706496 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -15,6 +15,11 @@ from typing import cast, Dict, List TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) os.chdir(os.path.dirname(TOOLS_DIR)) +sys.path.append(os.path.dirname(TOOLS_DIR)) +from lib import sanity_check +sanity_check.check_venv(__file__) +from lib.test_script import get_provisioning_status + exclude_common = """ zproject/settings.py zproject/test_settings.py @@ -47,12 +52,22 @@ parser.add_argument('--no-ignore-missing-imports', dest='ignore_missing_imports' help="""Don't use the --ignore-missing-imports flag with mypy""") parser.add_argument('--quick', action='store_true', default=False, help="""Use the --quick flag with mypy""") +parser.add_argument('--force', default=False, + action="store_true", + help='Run tests despite possible provisioning problems.') group = parser.add_mutually_exclusive_group() group.add_argument('--py2', default=False, action='store_true', help="Use Python 2 mode") group.add_argument('--py3', default=False, action='store_true', help="Use Python 3 mode") args = parser.parse_args() +if not args.force: + ok, msg = get_provisioning_status() + if not ok: + print(msg) + print('If you really know what you are doing, use --force to run anyway.') + sys.exit(1) + if args.py2: py_version = 2 elif args.py3: