From d137ca05fbe362c0eea43d4304ce4ef7373fde10 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Sun, 10 Nov 2024 20:34:16 -0500 Subject: [PATCH] Specify Python version to Mypy and PyType Also enable verbosity for `make` commands to see more information to help debugging in case there are errors. --- .github/workflows/main.yml | 6 +++--- Makefile | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0621ed1..a416966 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,13 +77,13 @@ jobs: if: ${{ matrix.python == '3.12' }} - name: Run Python tests - run: make py-test + run: make py-test VERBOSE=1 - name: Check types with Mypy - run: make mypy-test + run: make mypy-test PYTHON_VERSION=${{ matrix.python }} VERBOSE=1 - name: Check types with PyType - run: make pytype-test + run: make pytype-test PYTHON_VERSION=${{ matrix.python }} VERBOSE=1 # https://github.com/google/pytype/issues/1475 # # PyType does not yet support Python 3.12; if this step is enabled, it diff --git a/Makefile b/Makefile index 4fbc3d0..acf0f97 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ ifeq ($(VERBOSE),1) endif SRC_DIR ?= . +PYTHON_VERSION ?= $(shell python -c 'import platform; print(platform.python_version())') .PHONY: test clean @@ -45,7 +46,7 @@ py-test: $(VERB) $(SRC_DIR)/run_python_tests.sh mypy-test: - $(VERB) python -m mypy --ignore-missing-imports `find . -name 'third_party' -prune -o -name '*.py' -print` + $(VERB) python -m mypy --python-version=$(PYTHON_VERSION) --ignore-missing-imports `find . -name 'third_party' -prune -o -name '*.py' -print` pytype-test: - $(VERB) python -m pytype -k `find . -name 'third_party' -prune -o -name '*.py' -print` + $(VERB) python -m pytype --python-version=$(PYTHON_VERSION) -k `find . -name 'third_party' -prune -o -name '*.py' -print`