From dc31f9fd61bc523dade9042dcb1bac79eff6dea5 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 8 Dec 2025 18:37:34 +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. It also removes the slowest pre-commit hook (by some distance), making pre-commit faster. Change-Id: Ie241768231f180d5a672bf9f8fdc6a1eb8d7dfdb Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 35 ----------------------------------- pyproject.toml | 1 - tox.ini | 14 ++++++++++---- 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e0db4c1b0..3ab0cee8a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,41 +58,6 @@ repos: - id: codespell args: ['--ignore-words=doc/dictionary.txt'] - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.18.2 - hooks: - - id: mypy - additional_dependencies: - - types-paramiko - # keep this in-sync with '[tool.mypy] files' in 'pyproject.toml' - files: | - (?x)( - nova/compute/manager.py - | nova/compute/pci_placement_translator.py - | nova/crypto.py - | nova/filesystem.py - | nova/limit/local.py - | nova/limit/placement.py - | nova/network/neutron.py - | nova/pci - | nova/privsep/path.py - | nova/scheduler/client/report.py - | nova/scheduler/request_filter.py - | nova/scheduler/utils.py - | nova/virt/driver.py - | nova/virt/hardware.py - | nova/virt/libvirt/machine_type_utils.py - | nova/virt/libvirt/__init__.py - | nova/virt/libvirt/cpu/__init__.py - | nova/virt/libvirt/cpu/api.py - | nova/virt/libvirt/cpu/core.py - | nova/virt/libvirt/driver.py - | nova/virt/libvirt/event.py - | nova/virt/libvirt/guest.py - | nova/virt/libvirt/host.py - | nova/virt/libvirt/utils.py - ) - - repo: https://github.com/sphinx-contrib/sphinx-lint rev: v1.0.1 hooks: diff --git a/pyproject.toml b/pyproject.toml index c3bb5c04e2..4fcc94b8ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -124,7 +124,6 @@ follow_imports = "skip" incremental = true check_untyped_defs = true warn_unused_ignores = true -# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml' files = [ "nova/compute/manager.py", "nova/compute/pci_placement_translator.py", diff --git a/tox.ini b/tox.ini index 505a0bc834..c7e59ae163 100644 --- a/tox.ini +++ b/tox.ini @@ -131,18 +131,24 @@ description = Run style checks. deps = pre-commit -extras = + {[testenv:mypy]deps} commands = pre-commit run --all-files --show-diff-on-failure + {[testenv:mypy]commands} [testenv:mypy] description = Run type checks. +# TODO(stephenfin): At some point we might wish to create a 'types' extra deps = - pre-commit -extras = + mypy + types-decorator + types-paramiko + types-python-dateutil + types-PyYAML + types-setuptools commands = - pre-commit run --all-files --show-diff-on-failure mypy + mypy [testenv:autopep8] extras =