From fad3b6f8bcb6ffa45a6dac9ee29b09626a5ee3d9 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 1 Aug 2025 11:30:03 +0100 Subject: [PATCH] pre-commit: Use local neutron hacking checks This patch requires a new neutron-lib release (3.21.1) containing the depends on one. Change-Id: I880dc9e7f0d3cd578168e5c1435275901fc68f1f Signed-off-by: Stephen Finucane Depends-On: https://review.opendev.org/c/openstack/neutron-lib/+/956353 --- .pre-commit-config.yaml | 2 +- requirements.txt | 2 +- tox.ini | 46 +++++++++++++++++++---------------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 979642b6fa5..0e16df8b3c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: rev: 7.0.0 hooks: - id: hacking - additional_dependencies: ['neutron', 'neutron-lib'] + additional_dependencies: ['neutron-lib>=3.21.1'] exclude: '^(doc|releasenotes|tools)/.*$' - repo: https://github.com/hhatto/autopep8 rev: v2.3.2 diff --git a/requirements.txt b/requirements.txt index 3b17eff9f13..515a682a277 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ requests>=2.32.3 # Apache-2.0 Jinja2>=2.10 # BSD License (3 clause) keystonemiddleware>=5.1.0 # Apache-2.0 netaddr>=0.7.18 # BSD -neutron-lib>=3.21.0 # Apache-2.0 +neutron-lib>=3.21.1 # Apache-2.0 python-neutronclient>=7.8.0 # Apache-2.0 tenacity>=6.0.0 # Apache-2.0 SQLAlchemy>=1.4.23 # MIT diff --git a/tox.ini b/tox.ini index cb2d50fe79c..a57c51e0ae5 100644 --- a/tox.ini +++ b/tox.ini @@ -208,37 +208,33 @@ select = H,N # H204: Use assert(Not)Equal to check for equality # H205: Use assert(Greater|Less)(Equal) for comparison # H904: Delay string interpolations at logging calls -enable-extensions = H106,H203,H204,H205,H904 +# N521: jsonutils must be used instead of json +# N524: Use of contextlib.nested is deprecated +# N529: Method's default argument shouldn't be mutable +# N530: Direct neutron imports not allowed +# N535: Usage of Python eventlet module not allowed +# N536: Use assertIsNone +enable-extensions = H106,H203,H204,H205,H904,N521,N524,N529,N530,N532,N534,N535,N536 ignore = H405,H701,H702,H703,N530,N535 show-source = true exclude = ./.*,build,dist,doc [flake8:local-plugins] extension = - # Checks specific to neutron repo - N322 = neutron.hacking.checks:check_assert_called_once_with - N328 = neutron.hacking.checks:check_asserttruefalse - N329 = neutron.hacking.checks:check_assertitemsequal - N330 = neutron.hacking.checks:check_assertempty - N332 = neutron.hacking.checks:check_assertequal_for_httpcode - N340 = neutron.hacking.checks:check_oslo_i18n_wrapper - N341 = neutron.hacking.checks:check_builtins_gettext - N343 = neutron.hacking.checks:check_no_imports_from_tests - N344 = neutron.hacking.checks:check_python3_no_filter - N346 = neutron.hacking.checks:check_no_sqlalchemy_event_import - N348 = neutron.hacking.checks:check_no_import_six - N349 = neutron.hacking.checks:check_no_import_packaging - N350 = neutron.hacking.checks:check_no_sqlalchemy_lazy_subquery - # Checks from neutron-lib - N521 = neutron_lib.hacking.checks:use_jsonutils - N524 = neutron_lib.hacking.checks:check_no_contextlib_nested - N529 = neutron_lib.hacking.checks:no_mutable_default_args - N530 = neutron_lib.hacking.checks:check_neutron_namespace_imports - N532 = neutron_lib.hacking.translation_checks:check_log_warn_deprecated - N534 = neutron_lib.hacking.translation_checks:check_raised_localized_exceptions - N535 = neutron_lib.hacking.checks:check_no_eventlet_imports - N536 = neutron_lib.hacking.checks:assert_equal_none - N537 = neutron_lib.hacking.translation_checks:no_translate_logs + N322 = checks:check_assert_called_once_with + N328 = checks:check_asserttruefalse + N329 = checks:check_assertitemsequal + N330 = checks:check_assertempty + N332 = checks:check_assertequal_for_httpcode + N340 = checks:check_oslo_i18n_wrapper + N341 = checks:check_builtins_gettext + N343 = checks:check_no_imports_from_tests + N344 = checks:check_python3_no_filter + N346 = checks:check_no_sqlalchemy_event_import + N348 = checks:check_no_import_six + N349 = checks:check_no_import_packaging + N350 = checks:check_no_sqlalchemy_lazy_subquery +paths = ./neutron/hacking [doc8] max-line-length = 79