From d4bd95fd8699893392dc76de05478b54928d30af Mon Sep 17 00:00:00 2001 From: Philipp Hahn Date: Mon, 16 Nov 2020 20:08:42 +0100 Subject: [PATCH] Fix hard-coded pytype version (#4771) [tests/pytype_test.py](./tests/pytype_test.py#L176) is still using Python `3.6`: > python_version="2.7" if version == 2 else "3.6", The test fails to run if `python3.6` is unavailable (for example on Debian 10 Buster, which has 3.7). According to (https://devguide.python.org/#status-of-python-branches `3.6` is still maintained until end of 2021. `pytype` itself [claims](https://github.com/google/pytype#requirements) to run on `2.7`, `3.5`-`3.8`. Change the script to use the version of Python from the invoking interpreter. --- tests/pytype_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pytype_test.py b/tests/pytype_test.py index bd8c6bf91..898867fdf 100755 --- a/tests/pytype_test.py +++ b/tests/pytype_test.py @@ -13,6 +13,7 @@ will also discover incorrect usage of imported modules. import argparse import os import re +import sys import traceback from typing import List, Match, Optional, Sequence, Tuple @@ -173,7 +174,7 @@ def run_all_tests(*, files_to_test: Sequence[Tuple[str, int]], typeshed_location stderr = ( run_pytype( filename=f, - python_version="2.7" if version == 2 else "3.6", + python_version="2.7" if version == 2 else "{0.major}.{0.minor}".format(sys.version_info), typeshed_location=typeshed_location, ) if not dry_run