Merge "[pre-commit] Add initial pre-commit config"

This commit is contained in:
Zuul 2024-10-24 04:23:49 +00:00 committed by Gerrit Code Review
commit e8f9e31541
23 changed files with 132 additions and 58 deletions

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

@ -0,0 +1,60 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# whitespace
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: '.*\.(svg)$'
- id: check-byte-order-marker
# file format and permissions
- id: check-ast
- id: debug-statements
- id: check-json
files: .*\.json$
- id: check-yaml
files: .*\.(yaml|yml)$
# FIXME(sean-k-mooney): we currently have some files
# with incorrect permission, resolve this in a follow up
# - id: check-executables-have-shebangs
# - id: check-shebang-scripts-are-executable
# git
- id: check-added-large-files
- id: check-case-conflict
- id: detect-private-key
- id: check-merge-conflict
- 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: 7.0.0
hooks:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
files: '^.*\.py$'
# FIXME(sean-k-mooney): we have many typos and some false
# positives that need to be added to the dictionary
# correct this in a followup change
# - repo: https://github.com/codespell-project/codespell
# rev: v2.3.0
# hooks:
# - id: codespell
# args: ['--ignore-words=doc/dictionary.txt']
# FIXME(sean-k-mooney): we have many sphinx issues fix them
# in a separate commit to make it easier to review
# - repo: https://github.com/sphinx-contrib/sphinx-lint
# rev: v1.0.0
# hooks:
# - id: sphinx-lint
# args: [--enable=default-role]
# files: ^doc/|releasenotes|api-guide
# types: [rst]

View File

@ -13,9 +13,9 @@
"node_vcpu_ratio": "16.0", "node_vcpu_ratio": "16.0",
"node_memory": "16383", "node_memory": "16383",
"node_memory_ratio": "1.5", "node_memory_ratio": "1.5",
"node_disk": "37" "node_disk": "37",
"node_disk_ratio": "1.0", "node_disk_ratio": "1.0",
"node_state": "up", "node_state": "up"
}, },
{ {
"server_uuid": "e2cb5f6f-fa1d-4ba2-be1e-0bf02fa86ba4", "server_uuid": "e2cb5f6f-fa1d-4ba2-be1e-0bf02fa86ba4",
@ -30,9 +30,9 @@
"node_vcpu_ratio": "16.0", "node_vcpu_ratio": "16.0",
"node_memory": "16383", "node_memory": "16383",
"node_memory_ratio": "1.5", "node_memory_ratio": "1.5",
"node_disk": "37" "node_disk": "37",
"node_disk_ratio": "1.0", "node_disk_ratio": "1.0",
"node_state": "up", "node_state": "up"
} }
] ]
} }

0
doc/dictionary.txt Normal file
View File

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,6 +32,7 @@ LOG = log.getLogger(__name__)
class WebhookController(rest.RestController): class WebhookController(rest.RestController):
"""REST controller for webhooks resource.""" """REST controller for webhooks resource."""
def __init__(self): def __init__(self):
super(WebhookController, self).__init__() super(WebhookController, self).__init__()
self.dc_client = rpcapi.DecisionEngineAPI() 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 # 'on_error' never fired for wsme+pecan pair. wsme @wsexpose decorator
# catches and handles all the errors, so 'on_error' dedicated for unhandled # catches and handles all the errors, so 'on_error' dedicated for unhandled
# exceptions never fired. # exceptions never fired.
def after(self, state): def after(self, state):
# Omit empty body. Some errors may not have body at this level yet. # Omit empty body. Some errors may not have body at this level yet.
if not state.response.body: if not state.response.body:

View File

@ -33,6 +33,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
for public routes in the API. for public routes in the API.
""" """
def __init__(self, app, conf, public_api_routes=()): def __init__(self, app, conf, public_api_routes=()):
route_pattern_tpl = r'%s(\.json|\.xml)?$' 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. We need at least two atoms to create a link.
""" """
def execute(self): def execute(self):
pass pass

View File

@ -71,7 +71,6 @@ def init(policy_file=None, rules=None,
def enforce(context, rule=None, target=None, def enforce(context, rule=None, target=None,
do_raise=True, exc=None, *args, **kwargs): do_raise=True, exc=None, *args, **kwargs):
"""Checks authorization of a rule against the target and credentials. """Checks authorization of a rule against the target and credentials.
:param dict context: As much information about the user performing the :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) - Storage-related knowledge (Cinder)
""" """
def __init__(self, osc): def __init__(self, osc):
self.osc = osc self.osc = osc
self.model = model_root.StorageModelRoot() self.model = model_root.StorageModelRoot()

View File

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