From bbb2ed14957aadc56fe9eba6ed68e7f92079102b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 1 Dec 2025 12:59:07 +0000 Subject: [PATCH] Run mypy from tox This avoids the need to duplicate our dependency list in multiple places and allows us to take advantage of tox's dependency management infrastructure, to ensure we always get the latest and greatest version of a package allowed by upper-constraints. Signed-off-by: Stephen Finucane Change-Id: I3011f918ebcb0d25c80f40d6a95025bb97f4e6b5 --- .pre-commit-config.yaml | 16 +--------------- pyproject.toml | 9 ++------- tox.ini | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bb0809..248a7d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.4 + rev: v0.14.7 hooks: - id: ruff-check args: ['--fix', '--unsafe-fixes'] @@ -24,17 +24,3 @@ repos: - id: hacking additional_dependencies: [] exclude: '^(doc|releasenotes)/.*$' - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.0 - hooks: - - id: mypy - additional_dependencies: - - Sphinx - - types-docutils - # keep this in-sync with '[mypy] exclude' in 'pyproject.toml' - exclude: | - (?x)( - doc/.* - | examples/.* - | releasenotes/.* - ) diff --git a/pyproject.toml b/pyproject.toml index d6f10e4..b0c7896 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,14 +50,9 @@ packages = [ python_version = "3.10" show_column_numbers = true show_error_context = true -ignore_missing_imports = true strict = true -# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml' -exclude = '''(?x)( - doc - | examples - | releasenotes -)''' +ignore_missing_imports = true +exclude = '(?x)(doc | examples | releasenotes)' [[tool.mypy.overrides]] module = ["stevedore.tests.*"] diff --git a/tox.ini b/tox.ini index 875f54b..f2555b8 100644 --- a/tox.ini +++ b/tox.ini @@ -19,12 +19,23 @@ commands = {posargs} [testenv:pep8] description = - Run style checks. -skip_install = true + Run style checks. deps = pre-commit + {[testenv:mypy]deps} commands = pre-commit run -a + {[testenv:mypy]commands} + +[testenv:mypy] +description = + Run type checks. +deps = + {[testenv]deps} + mypy + types-docutils +commands = + mypy --cache-dir="{envdir}/mypy_cache" {posargs:stevedore} [testenv:docs] deps =