[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:
parent
0f96f99404
commit
9d8b990fd1
60
.pre-commit-config.yaml
Normal file
60
.pre-commit-config.yaml
Normal 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]
|
@ -13,9 +13,9 @@
|
||||
"node_vcpu_ratio": "16.0",
|
||||
"node_memory": "16383",
|
||||
"node_memory_ratio": "1.5",
|
||||
"node_disk": "37"
|
||||
"node_disk": "37",
|
||||
"node_disk_ratio": "1.0",
|
||||
"node_state": "up",
|
||||
"node_state": "up"
|
||||
},
|
||||
{
|
||||
"server_uuid": "e2cb5f6f-fa1d-4ba2-be1e-0bf02fa86ba4",
|
||||
@ -30,9 +30,9 @@
|
||||
"node_vcpu_ratio": "16.0",
|
||||
"node_memory": "16383",
|
||||
"node_memory_ratio": "1.5",
|
||||
"node_disk": "37"
|
||||
"node_disk": "37",
|
||||
"node_disk_ratio": "1.0",
|
||||
"node_state": "up",
|
||||
"node_state": "up"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
0
doc/dictionary.txt
Normal file
0
doc/dictionary.txt
Normal file
@ -229,6 +229,7 @@ class ActionCollection(collection.Collection):
|
||||
|
||||
class ActionsController(rest.RestController):
|
||||
"""REST controller for Actions."""
|
||||
|
||||
def __init__(self):
|
||||
super(ActionsController, self).__init__()
|
||||
|
||||
|
@ -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()
|
||||
|
@ -475,6 +475,7 @@ class AuditTemplateCollection(collection.Collection):
|
||||
|
||||
class AuditTemplatesController(rest.RestController):
|
||||
"""REST controller for AuditTemplates."""
|
||||
|
||||
def __init__(self):
|
||||
super(AuditTemplatesController, self).__init__()
|
||||
|
||||
|
@ -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__()
|
||||
|
||||
|
@ -153,6 +153,7 @@ class GoalCollection(collection.Collection):
|
||||
|
||||
class GoalsController(rest.RestController):
|
||||
"""REST controller for Goals."""
|
||||
|
||||
def __init__(self):
|
||||
super(GoalsController, self).__init__()
|
||||
|
||||
|
@ -145,6 +145,7 @@ class ScoringEngineCollection(collection.Collection):
|
||||
|
||||
class ScoringEngineController(rest.RestController):
|
||||
"""REST controller for Scoring Engines."""
|
||||
|
||||
def __init__(self):
|
||||
super(ScoringEngineController, self).__init__()
|
||||
|
||||
|
@ -175,6 +175,7 @@ class ServiceCollection(collection.Collection):
|
||||
|
||||
class ServicesController(rest.RestController):
|
||||
"""REST controller for Services."""
|
||||
|
||||
def __init__(self):
|
||||
super(ServicesController, self).__init__()
|
||||
|
||||
|
@ -196,6 +196,7 @@ class StrategyCollection(collection.Collection):
|
||||
|
||||
class StrategiesController(rest.RestController):
|
||||
"""REST controller for Strategies."""
|
||||
|
||||
def __init__(self):
|
||||
super(StrategiesController, self).__init__()
|
||||
|
||||
|
@ -161,6 +161,7 @@ class MultiType(wtypes.UserType):
|
||||
:param types: Variable-length list of types.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, *types):
|
||||
self.types = types
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -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)?$'
|
||||
|
||||
|
@ -199,5 +199,6 @@ class TaskFlowNop(flow_task.Task):
|
||||
|
||||
We need at least two atoms to create a link.
|
||||
"""
|
||||
|
||||
def execute(self):
|
||||
pass
|
||||
|
@ -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
|
||||
|
@ -165,6 +165,7 @@ class CinderModelBuilder(base.BaseModelBuilder):
|
||||
- Storage-related knowledge (Cinder)
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, osc):
|
||||
self.osc = osc
|
||||
self.model = model_root.StorageModelRoot()
|
||||
|
@ -78,6 +78,7 @@ class BareMetalModelBuilder(base.BaseModelBuilder):
|
||||
|
||||
- Baremetal-related knowledge (Ironic)
|
||||
"""
|
||||
|
||||
def __init__(self, osc):
|
||||
self.osc = osc
|
||||
self.model = model_root.BaremetalModelRoot()
|
||||
|
Loading…
Reference in New Issue
Block a user