From 434ef3018e51486f10eadcc8abd61fa746900d5d Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 9 Jan 2025 18:10:01 -0500 Subject: [PATCH] Enable mypy pre-commit hook Change-Id: I266a2866627fcf66d0f5111c9237a37e55414685 --- .pre-commit-config.yaml | 10 ++++++++++ mypy.ini | 2 ++ tox.ini | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 253c9eebedf..e9aee93c07a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,6 +47,16 @@ repos: - id: hacking additional_dependencies: ['neutron', 'neutron-lib'] exclude: '^(doc|releasenotes|tools)/.*$' + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.14.1 + hooks: + - id: mypy + args: [--config-file=./mypy.ini] + pass_filenames: false + # need to list alembic here; otherwise it doesn't see internals + # necessary to detect one of 'ignored' errors and complains about + # unnecessary ignore; other dependencies can be left out it seems + additional_dependencies: ['alembic'] - repo: local hooks: - id: flake8 diff --git a/mypy.ini b/mypy.ini index 7898941a388..b65d4d47c8f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -12,6 +12,8 @@ disable_error_code = import-untyped,var-annotated,import-not-found # honor excludes by not following there through imports follow_imports = silent +files = neutron + # NOTE: Gradually enable type checking for each package. # Finally, when the whole repo is migrated this option can be deleted # and rules applied to the whole repo. diff --git a/tox.ini b/tox.ini index fbabc99a3d1..426706bbfc0 100644 --- a/tox.ini +++ b/tox.ini @@ -123,7 +123,7 @@ commands = [testenv:mypy] deps = {[testenv:pep8]deps} -commands = mypy --config-file ./mypy.ini neutron +commands = mypy --config-file ./mypy.ini [testenv:releasenotes] description =