Add pre-commit

Change-Id: Ifdee3615f26b370cda531ae0cc736b8db67ed204
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-01-23 11:58:55 +00:00
parent 54253708f0
commit 40f7c167d8
6 changed files with 42 additions and 11 deletions

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

@ -0,0 +1,30 @@
---
default_language_version:
# force all unspecified python hooks to run python3
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.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)$
args: ['--unsafe']
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
args: ['-S', '-l', '79']
- repo: https://opendev.org/openstack/hacking
rev: 6.1.0
hooks:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'

View File

@ -16,6 +16,4 @@
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
setuptools.setup(
setup_requires=['pbr>=2.0.0'],
pbr=True)
setuptools.setup(setup_requires=['pbr>=2.0.0'], pbr=True)

View File

@ -1,3 +1,2 @@
hacking>=3.0,<3.1.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0

View File

@ -71,7 +71,6 @@ def find_duplicates():
# Iterate over all entry points
for ep in pkg_resources.iter_entry_points(module):
# Check for a colon, since valid entrypoints will have one, for
# example: quota_show = openstackclient.common.quota:ShowQuota
# and plugin entrypoints will not, for
@ -166,9 +165,11 @@ def _is_valid_command(ep_name, ep_module_name, valid_cmds):
module_parts = ep_module_name.split(".")
for valid_module_name in valid_cmds[ep_name]:
valid_module_parts = valid_module_name.split(".")
if (module_parts[0] == valid_module_parts[0] and
module_parts[1] == valid_module_parts[1] and
module_parts[3] == valid_module_parts[3]):
if (
module_parts[0] == valid_module_parts[0]
and module_parts[1] == valid_module_parts[1]
and module_parts[3] == valid_module_parts[3]
):
return True
return False

View File

@ -14,6 +14,5 @@ from oslotest import base
class TestOpenstackClient(base.BaseTestCase):
def test_something(self):
pass

View File

@ -10,8 +10,12 @@ commands =
stestr run --slowest {posargs}
[testenv:pep8]
description =
Run style checks.
deps =
pre-commit
commands =
flake8
pre-commit run --all-files --show-diff-on-failure
[testenv:venv]
commands = {posargs}
@ -26,4 +30,4 @@ commands =
[flake8]
show-source = True
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,__init__.py
ignore = E123,H405,W504
ignore = E123,H405,W503