[pre-commit] Add initial pre-commit config

This change adds configuration for the pre-commit tool,
follow-up changes will address the remaining issues in a phased
approach to make the reviews simpler.

This is based on the pre-commit config used in nova
with some additional hooks.

Follow-up changes will address the FIXME comments
related to sphinx-lint and codespell, as well as update tox
to enforce these checks in ci.

Change-Id: I87681a19f7fa88366c2b0d310c8b3153aa6a137b
This commit is contained in:
Sean Mooney
2024-10-22 18:19:56 +01:00
parent 0f96f99404
commit 9d8b990fd1
23 changed files with 132 additions and 58 deletions

View File

@@ -229,6 +229,7 @@ class ActionCollection(collection.Collection):
class ActionsController(rest.RestController):
"""REST controller for Actions."""
def __init__(self):
super(ActionsController, self).__init__()

View File

@@ -468,6 +468,7 @@ class AuditCollection(collection.Collection):
class AuditsController(rest.RestController):
"""REST controller for Audits."""
def __init__(self):
super(AuditsController, self).__init__()
self.dc_client = rpcapi.DecisionEngineAPI()

View File

@@ -475,6 +475,7 @@ class AuditTemplateCollection(collection.Collection):
class AuditTemplatesController(rest.RestController):
"""REST controller for AuditTemplates."""
def __init__(self):
super(AuditTemplatesController, self).__init__()

View File

@@ -32,6 +32,7 @@ from watcher.decision_engine import rpcapi
class DataModelController(rest.RestController):
"""REST controller for data model"""
def __init__(self):
super(DataModelController, self).__init__()

View File

@@ -153,6 +153,7 @@ class GoalCollection(collection.Collection):
class GoalsController(rest.RestController):
"""REST controller for Goals."""
def __init__(self):
super(GoalsController, self).__init__()

View File

@@ -145,6 +145,7 @@ class ScoringEngineCollection(collection.Collection):
class ScoringEngineController(rest.RestController):
"""REST controller for Scoring Engines."""
def __init__(self):
super(ScoringEngineController, self).__init__()

View File

@@ -175,6 +175,7 @@ class ServiceCollection(collection.Collection):
class ServicesController(rest.RestController):
"""REST controller for Services."""
def __init__(self):
super(ServicesController, self).__init__()

View File

@@ -196,6 +196,7 @@ class StrategyCollection(collection.Collection):
class StrategiesController(rest.RestController):
"""REST controller for Strategies."""
def __init__(self):
super(StrategiesController, self).__init__()

View File

@@ -161,6 +161,7 @@ class MultiType(wtypes.UserType):
:param types: Variable-length list of types.
"""
def __init__(self, *types):
self.types = types

View File

@@ -32,6 +32,7 @@ LOG = log.getLogger(__name__)
class WebhookController(rest.RestController):
"""REST controller for webhooks resource."""
def __init__(self):
super(WebhookController, self).__init__()
self.dc_client = rpcapi.DecisionEngineAPI()

View File

@@ -83,6 +83,7 @@ class NoExceptionTracebackHook(hooks.PecanHook):
# 'on_error' never fired for wsme+pecan pair. wsme @wsexpose decorator
# catches and handles all the errors, so 'on_error' dedicated for unhandled
# exceptions never fired.
def after(self, state):
# Omit empty body. Some errors may not have body at this level yet.
if not state.response.body:

View File

@@ -33,6 +33,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
for public routes in the API.
"""
def __init__(self, app, conf, public_api_routes=()):
route_pattern_tpl = r'%s(\.json|\.xml)?$'

View File

@@ -199,5 +199,6 @@ class TaskFlowNop(flow_task.Task):
We need at least two atoms to create a link.
"""
def execute(self):
pass

View File

@@ -71,7 +71,6 @@ def init(policy_file=None, rules=None,
def enforce(context, rule=None, target=None,
do_raise=True, exc=None, *args, **kwargs):
"""Checks authorization of a rule against the target and credentials.
:param dict context: As much information about the user performing the

View File

@@ -165,6 +165,7 @@ class CinderModelBuilder(base.BaseModelBuilder):
- Storage-related knowledge (Cinder)
"""
def __init__(self, osc):
self.osc = osc
self.model = model_root.StorageModelRoot()

View File

@@ -78,6 +78,7 @@ class BareMetalModelBuilder(base.BaseModelBuilder):
- Baremetal-related knowledge (Ironic)
"""
def __init__(self, osc):
self.osc = osc
self.model = model_root.BaremetalModelRoot()