From cd4c589f8c0a9677b74437efd62942d6781de992 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 7 Dec 2023 18:35:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Run=20MyPy=20against=20supported?= =?UTF-8?q?=20Python=20range?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch moves the MyPy invocation from `Makefile` to the `pre-commit` tool and introduces a number of runtimes to check. --- .pre-commit-config.yaml | 44 +++++++++++++++++++++++++++++++++++++++++ Makefile | 5 +++-- mypy.ini | 1 + requirements/ci.txt | 1 - 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b009b525..c60064ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -84,6 +84,50 @@ repos: ^[^/]+[.]rst$ exclude: >- ^CHANGES\.rst$ + +- repo: https://github.com/pre-commit/mirrors-mypy.git + rev: v1.7.1 + hooks: + - id: mypy + alias: mypy-py312 + name: MyPy, for Python 3.12 + additional_dependencies: + - lxml # requirement of `--txt-report` + args: + - --show-error-codes + - --install-types + - --non-interactive + - --python-version=3.12 + - --txt-report=.tox/.tmp/.mypy/python-3.12 + - frozenlist/ + pass_filenames: false + - id: mypy + alias: mypy-py310 + name: MyPy, for Python 3.10 + additional_dependencies: + - lxml # requirement of `--txt-report` + args: + - --show-error-codes + - --install-types + - --non-interactive + - --python-version=3.10 + - --txt-report=.tox/.tmp/.mypy/python-3.10 + - frozenlist/ + pass_filenames: false + - id: mypy + alias: mypy-py38 + name: MyPy, for Python 3.8 + additional_dependencies: + - lxml # requirement of `--txt-report` + args: + - --show-error-codes + - --install-types + - --non-interactive + - --python-version=3.8 + - --txt-report=.tox/.tmp/.mypy/python-3.8 + - frozenlist/ + pass_filenames: false + - repo: https://github.com/rhysd/actionlint rev: v1.6.26 hooks: diff --git a/Makefile b/Makefile index e3804999..bef22e80 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,10 @@ endif lint: .install-deps ifndef CI - python -m pre_commit run --all-files + python -Im pre_commit run --all-files +else + python -Im pre_commit run mypy --all-files endif - python -m mypy frozenlist --show-error-codes .develop: .install-deps $(shell find frozenlist -type f) lint pip install -e . diff --git a/mypy.ini b/mypy.ini index 873e3bda..ba7fcca6 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,6 @@ [mypy] follow_imports = silent +show_error_codes = true strict_optional = True warn_redundant_casts = True diff --git a/requirements/ci.txt b/requirements/ci.txt index c83a69b1..d34256d1 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,7 +1,6 @@ build==1.0.3 coverage==7.3.2 cython==3.0.6 -mypy==1.7.1; implementation_name=="cpython" pre-commit==3.5.0 pytest==7.4.3 pytest-cov==4.1.0