Add pre-commit

Better linting. We fix the issues this highlights in the process.

Change-Id: I02ce11b497988bc0165f20fbca678d13bed5827e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-04-12 15:01:10 +01:00 committed by Dmitriy Rabotyagov
parent fcff141f14
commit c0ed7726d8
18 changed files with 61 additions and 35 deletions

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

@ -0,0 +1,27 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-json
files: .*\.json$
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs
exclude: '.*\.(svg)$'
- repo: https://opendev.org/openstack/hacking
rev: 6.1.0
hooks:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'

View File

@ -6,6 +6,5 @@
"hostname": "szaher01",
"uuid": "6f588392aa864c96b4af96a4eae005ce",
"client_id": "752d8bd43d654e7a840bbfda77ce41af_szaher01"
},
}
}

View File

@ -17,8 +17,8 @@
"log_file": "/home/saad/job0001.log",
"snapshot": true,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
}
}
]
]
}

View File

@ -28,7 +28,7 @@
"log_file": "/home/saad/job0001.log",
"snapshot": false,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
},
"max_retries": 5,
"max_retries_interval": 6,

View File

@ -18,8 +18,8 @@
"log_file": "/home/saad/job0001.log",
"snapshot": false,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
}
}
]
]
}

View File

@ -30,7 +30,7 @@
"log_file": "/home/saad/job0001.log",
"snapshot": false,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
},
"max_retries": 5,
"max_retries_interval": 6,

0
devstack/plugin.sh Executable file → Normal file
View File

View File

@ -180,7 +180,7 @@ class DbActionTestCase(base.DbTestCase):
def test_add_and_search_action(self):
count = 0
actionids = []
while(count < 20):
while (count < 20):
doc = copy.deepcopy(self.fake_action_3)
action_id = common.get_fake_action_id()
doc['action_id'] = action_id

View File

@ -188,7 +188,7 @@ class DbActionTestCase(base.DbTestCase):
def test_add_and_search_action(self):
count = 0
actionids = []
while(count < 20):
while (count < 20):
doc = copy.deepcopy(self.fake_action_3)
action_id = common.get_fake_action_id()
doc['action_id'] = action_id

View File

@ -128,8 +128,8 @@ class TestJobDoc(common.FreezerBaseTestCase):
def test_createpatch_pops_jobid_and_userid(self):
job_doc = common.get_fake_job_0()
res_doc = utils.JobDoc.create_patch(job_doc)
self.assertFalse('job_id' in res_doc)
self.assertFalse('user_id' in res_doc)
self.assertNotIn('job_id', res_doc)
self.assertNotIn('user_id', res_doc)
def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_state(
self):
@ -207,8 +207,8 @@ class TestActionDoc(common.FreezerBaseTestCase):
def test_createpatch_pops_actionid_and_userid(self):
action_doc = common.get_fake_action_0()
res_doc = utils.ActionDoc.create_patch(action_doc)
self.assertFalse('action_id' in res_doc)
self.assertFalse('user_id' in res_doc)
self.assertNotIn('action_id', res_doc)
self.assertNotIn('user_id', res_doc)
def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_field(
self):
@ -269,8 +269,8 @@ class TestSessionDoc(common.FreezerBaseTestCase):
def test_createpatch_pops_sessionid_and_userid(self):
session_doc = common.get_fake_session_0()
res_doc = utils.SessionDoc.create_patch(session_doc)
self.assertFalse('session_id' in res_doc)
self.assertFalse('user_id' in res_doc)
self.assertNotIn('session_id', res_doc)
self.assertNotIn('user_id', res_doc)
def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_field(
self):

View File

@ -2,8 +2,6 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# hacking already pins flake8
hacking>=3.0.1,<=3.1.0 # Apache-2.0
pylint>=2.4.0 # GPLv2
coverage>=4.5.1 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -32,8 +32,10 @@ commands =
pylint --rcfile .pylintrc freezer_api
[testenv:pep8]
deps =
pre-commit
commands =
flake8 freezer_api
pre-commit run --all-files --show-diff-on-failure
[testenv:docs]
commands =