From 533e24338aa281caace461635ea040b24c5001b2 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 6 Nov 2024 12:51:39 +0000 Subject: [PATCH] Integrate pre-commit Change-Id: I26049d9d0f5f4f30a8e94f2d7b80eb70ada48e8c Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 22 +++++++++++++++++++ os_vif/tests/unit/test_os_vif.py | 22 ++++++++++++------- ...tevedore-entrypoints-8002ec7a5166c977.yaml | 2 +- tox.ini | 8 +++++-- 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..99ed34e4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: mixed-line-ending + args: ['--fix', 'lf'] + exclude: '.*\.(svg)$' + - id: check-byte-order-marker + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: debug-statements + - id: check-yaml + files: .*\.(yaml|yml)$ + exclude: '^zuul.d/.*$' + - repo: https://opendev.org/openstack/hacking + rev: 7.0.0 + hooks: + - id: hacking + additional_dependencies: [] + exclude: '^(doc|releasenotes)/.*$' diff --git a/os_vif/tests/unit/test_os_vif.py b/os_vif/tests/unit/test_os_vif.py index c76c6d49..4c137d6e 100644 --- a/os_vif/tests/unit/test_os_vif.py +++ b/os_vif/tests/unit/test_os_vif.py @@ -105,10 +105,13 @@ class TestOSVIF(base.TestCase): entry_point="os-vif", plugin=DemoPlugin, obj=None) - with mock.patch('stevedore.extension.ExtensionManager.names', - return_value=['foobar']),\ - mock.patch('stevedore.extension.ExtensionManager.__getitem__', - return_value=plg): + with mock.patch( + 'stevedore.extension.ExtensionManager.names', + return_value=['foobar'], + ), mock.patch( + 'stevedore.extension.ExtensionManager.__getitem__', + return_value=plg, + ): os_vif.initialize() info = objects.instance_info.InstanceInfo() vif = objects.vif.VIFBridge( @@ -123,10 +126,13 @@ class TestOSVIF(base.TestCase): entry_point="os-vif", plugin=DemoPlugin, obj=None) - with mock.patch('stevedore.extension.ExtensionManager.names', - return_value=['foobar']),\ - mock.patch('stevedore.extension.ExtensionManager.__getitem__', - return_value=plg): + with mock.patch( + 'stevedore.extension.ExtensionManager.names', + return_value=['foobar'] + ), mock.patch( + 'stevedore.extension.ExtensionManager.__getitem__', + return_value=plg, + ): os_vif.initialize() info = objects.instance_info.InstanceInfo() vif = objects.vif.VIFBridge( diff --git a/releasenotes/notes/fix-stevedore-entrypoints-8002ec7a5166c977.yaml b/releasenotes/notes/fix-stevedore-entrypoints-8002ec7a5166c977.yaml index 2ebe6320..04603176 100644 --- a/releasenotes/notes/fix-stevedore-entrypoints-8002ec7a5166c977.yaml +++ b/releasenotes/notes/fix-stevedore-entrypoints-8002ec7a5166c977.yaml @@ -1,6 +1,6 @@ --- fixes: - - os-vif plugins were previously incorrectly registered + - os-vif plugins were previously incorrectly registered in both the setup.py and setup.cfg. All plugin registration have been removed form the setup.py as they were not used and may have blocked registration of out of tree plugins. diff --git a/tox.ini b/tox.ini index d4a209bc..036249a1 100644 --- a/tox.ini +++ b/tox.ini @@ -55,9 +55,13 @@ commands = coverage report [testenv:pep8] +description = + Run style checks. +skip_install = true deps = - hacking>=3.0.1,<3.1.0 -commands = flake8 + pre-commit +commands = + pre-commit run --all-files --show-diff-on-failure [flake8] # E123, E125 skipped as they are invalid PEP-8.