Merge "Integrate pre-commit"

This commit is contained in:
Zuul 2025-01-08 15:45:03 +00:00 committed by Gerrit Code Review
commit 44ef76015d
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",
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(

View File

@ -57,9 +57,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.