Integrate pre-commit

Change-Id: I26049d9d0f5f4f30a8e94f2d7b80eb70ada48e8c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2024-11-06 12:51:39 +00:00
parent b272621f77
commit 533e24338a
4 changed files with 43 additions and 11 deletions

22
.pre-commit-config.yaml Normal file
View File

@ -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)/.*$'

View File

@ -105,10 +105,13 @@ class TestOSVIF(base.TestCase):
entry_point="os-vif", entry_point="os-vif",
plugin=DemoPlugin, plugin=DemoPlugin,
obj=None) obj=None)
with mock.patch('stevedore.extension.ExtensionManager.names', with mock.patch(
return_value=['foobar']),\ 'stevedore.extension.ExtensionManager.names',
mock.patch('stevedore.extension.ExtensionManager.__getitem__', return_value=['foobar'],
return_value=plg): ), mock.patch(
'stevedore.extension.ExtensionManager.__getitem__',
return_value=plg,
):
os_vif.initialize() os_vif.initialize()
info = objects.instance_info.InstanceInfo() info = objects.instance_info.InstanceInfo()
vif = objects.vif.VIFBridge( vif = objects.vif.VIFBridge(
@ -123,10 +126,13 @@ class TestOSVIF(base.TestCase):
entry_point="os-vif", entry_point="os-vif",
plugin=DemoPlugin, plugin=DemoPlugin,
obj=None) obj=None)
with mock.patch('stevedore.extension.ExtensionManager.names', with mock.patch(
return_value=['foobar']),\ 'stevedore.extension.ExtensionManager.names',
mock.patch('stevedore.extension.ExtensionManager.__getitem__', return_value=['foobar']
return_value=plg): ), mock.patch(
'stevedore.extension.ExtensionManager.__getitem__',
return_value=plg,
):
os_vif.initialize() os_vif.initialize()
info = objects.instance_info.InstanceInfo() info = objects.instance_info.InstanceInfo()
vif = objects.vif.VIFBridge( vif = objects.vif.VIFBridge(

View File

@ -1,6 +1,6 @@
--- ---
fixes: 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 in both the setup.py and setup.cfg. All plugin registration
have been removed form the setup.py as they were not used have been removed form the setup.py as they were not used
and may have blocked registration of out of tree plugins. and may have blocked registration of out of tree plugins.

View File

@ -55,9 +55,13 @@ commands =
coverage report coverage report
[testenv:pep8] [testenv:pep8]
description =
Run style checks.
skip_install = true
deps = deps =
hacking>=3.0.1,<3.1.0 pre-commit
commands = flake8 commands =
pre-commit run --all-files --show-diff-on-failure
[flake8] [flake8]
# E123, E125 skipped as they are invalid PEP-8. # E123, E125 skipped as they are invalid PEP-8.