pre-commit: Add autopep8

Change-Id: Ie0d191d6b4d5620c014cceddbb885c901a500d79
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-07-04 11:10:07 +01:00
parent 094867041d
commit aa520fec9c
14 changed files with 23 additions and 5 deletions

View File

@ -26,12 +26,12 @@ repos:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
files: '^.*\.py$'
# TODO(stephenfin): Uncomment this
# - repo: https://github.com/hhatto/autopep8
# rev: v2.3.1
# hooks:
# - id: autopep8
# files: '^.*\.py$'
# - repo: https://github.com/sphinx-contrib/sphinx-lint
# rev: v0.9.1
# hooks:

View File

@ -94,6 +94,7 @@ class PlacementAuthProtocol(auth_token.AuthProtocol):
for root in the API.
"""
def __init__(self, app, conf):
self._placement_app = app
super(PlacementAuthProtocol, self).__init__(app, conf)

View File

@ -29,6 +29,7 @@ class Checks(upgradecheck.UpgradeCommands):
Various upgrade checks should be added as separate methods in this class
and added to _upgrade_checks tuple.
"""
def __init__(self, config):
self.config = config
self.ctxt = context.RequestContext(config=config)

View File

@ -363,6 +363,7 @@ class RequestWideParams(object):
This is in contrast with individual request groups (list of RequestGroup
above).
"""
def __init__(self, limit=None, group_policy=None,
anchor_required_traits=None, anchor_forbidden_traits=None,
same_subtrees=None):

View File

@ -46,6 +46,7 @@ class RequestGroupSearchContext(object):
"""An adapter object that represents the search for allocation candidates
for a single request group.
"""
def __init__(self, context, group, has_trees, sharing, suffix=''):
"""Initializes the object retrieving and caching matching providers
for each conditions like resource and aggregates from database.
@ -182,6 +183,7 @@ class RequestWideSearchContext(object):
"""An adapter object that represents the search for allocation candidates
for a request-wide parameters.
"""
def __init__(self, context, rqparams, nested_aware):
"""Create a RequestWideSearchContext.

View File

@ -23,6 +23,7 @@ class RPCandidateList(object):
the resource provider ID, the second element being the root provider ID
and the third being resource class ID.
"""
def __init__(self, rp_candidates=None):
self.rp_candidates = rp_candidates or set()

View File

@ -32,6 +32,7 @@ class UpgradeCheckIncompleteConsumersTestCase(
"""Tests the "Incomplete Consumers" check for the
"placement-status upgrade check" command.
"""
def setUp(self):
super(UpgradeCheckIncompleteConsumersTestCase, self).setUp()
self.output = io.StringIO()

View File

@ -1027,6 +1027,7 @@ class ProviderTreeDBHelperTestCase(tb.PlacementDbBaseTestCase):
b = 'CUSTOM_B'
c = 'CUSTOM_C'
# autopep8: off
matching_trees = [
# CN C1 C2 C1_GC1
(1, [[a, b, c], [], [], [], ], ), # noqa
@ -1053,6 +1054,7 @@ class ProviderTreeDBHelperTestCase(tb.PlacementDbBaseTestCase):
(18, [[], [c], [], [], ], ), # noqa
(19, [[], [], [a], [], ], ), # noqa
]
# autopep8: on
matching_rp_ids = self.make_trees_with_traits_for_any_traits(
matching_trees)

View File

@ -26,6 +26,7 @@ class NullHandler(logging.Handler):
Used in conjunction with Logging below to detect formatting errors
in debug logs.
"""
def handle(self, record):
self.format(record)

View File

@ -156,6 +156,7 @@ class AllocationFixture(APIFixture):
| DISK_GB:2048 |
+------------------------+
"""
def start_fixture(self):
super(AllocationFixture, self).start_fixture()
@ -596,6 +597,7 @@ class DeepNUMANetworkFixture(NUMANetworkFixture):
parents and grandparents of the compute nodes. This is to exercise
same_subtree in a more complete fashion.
"""
def make_entities(self):
"""Create parents and grandparents for cn1 and cn2. They will be fully
populated by the superclass, NUMANetworkFixture.
@ -614,6 +616,7 @@ class NonSharedStorageFixture(APIFixture):
"""An APIFixture that has three compute nodes with local storage that do
not use shared storage.
"""
def start_fixture(self):
super(NonSharedStorageFixture, self).start_fixture()
@ -684,6 +687,7 @@ class GranularFixture(APIFixture):
|traits: MISC_SHARES... +.........+
+=======================+
"""
def start_fixture(self):
super(GranularFixture, self).start_fixture()

View File

@ -40,6 +40,7 @@ class PlacementFixture(fixtures.Fixture):
Used by other services, including nova, for functional tests.
"""
def __init__(self, token='admin', conf_fixture=None, db=True,
use_intercept=True, register_opts=True):
"""Create a Placement Fixture.

View File

@ -29,6 +29,7 @@ class TestAllocationProjectCreateRace(base.TestCase):
project in the same transaction which is inactive due to the previous
'Duplicate entry' error.
"""
def setUp(self):
super(TestAllocationProjectCreateRace, self).setUp()

View File

@ -29,6 +29,7 @@ class PolicyFixture(fixtures.Fixture):
super(PolicyFixture, self).__init__()
"""Load the default placement policy for tests."""
def setUp(self):
super(PolicyFixture, self).setUp()
policy_file = paths.state_path_def('etc/placement/policy.yaml')

View File

@ -27,6 +27,7 @@ from placement.tests.unit import policy_fixture
class PlacementPolicyTestCase(base.ContextTestCase):
"""Tests interactions with placement policy."""
def setUp(self):
super(PlacementPolicyTestCase, self).setUp()
config = cfg.ConfigOpts()