diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d5435f5f6..7cd94c2b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/placement/auth.py b/placement/auth.py index a3523b856..874915ab5 100644 --- a/placement/auth.py +++ b/placement/auth.py @@ -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) diff --git a/placement/cmd/status.py b/placement/cmd/status.py index d18f3bd57..5f031a8e6 100644 --- a/placement/cmd/status.py +++ b/placement/cmd/status.py @@ -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) diff --git a/placement/lib.py b/placement/lib.py index ddba8ad11..6548284f3 100644 --- a/placement/lib.py +++ b/placement/lib.py @@ -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): diff --git a/placement/objects/research_context.py b/placement/objects/research_context.py index 89034104d..c296596dd 100644 --- a/placement/objects/research_context.py +++ b/placement/objects/research_context.py @@ -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. diff --git a/placement/objects/rp_candidates.py b/placement/objects/rp_candidates.py index b5893fcac..ebd431983 100644 --- a/placement/objects/rp_candidates.py +++ b/placement/objects/rp_candidates.py @@ -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() diff --git a/placement/tests/functional/cmd/test_status.py b/placement/tests/functional/cmd/test_status.py index 8bf294277..aaac60f56 100644 --- a/placement/tests/functional/cmd/test_status.py +++ b/placement/tests/functional/cmd/test_status.py @@ -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() diff --git a/placement/tests/functional/db/test_allocation_candidates.py b/placement/tests/functional/db/test_allocation_candidates.py index c7735662e..f390f4880 100644 --- a/placement/tests/functional/db/test_allocation_candidates.py +++ b/placement/tests/functional/db/test_allocation_candidates.py @@ -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) diff --git a/placement/tests/functional/fixtures/capture.py b/placement/tests/functional/fixtures/capture.py index b2514c09a..9485b646d 100644 --- a/placement/tests/functional/fixtures/capture.py +++ b/placement/tests/functional/fixtures/capture.py @@ -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) diff --git a/placement/tests/functional/fixtures/gabbits.py b/placement/tests/functional/fixtures/gabbits.py index c5295b238..2ad7c6400 100644 --- a/placement/tests/functional/fixtures/gabbits.py +++ b/placement/tests/functional/fixtures/gabbits.py @@ -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() diff --git a/placement/tests/functional/fixtures/placement.py b/placement/tests/functional/fixtures/placement.py index 06453ac3e..fe1df252e 100644 --- a/placement/tests/functional/fixtures/placement.py +++ b/placement/tests/functional/fixtures/placement.py @@ -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. diff --git a/placement/tests/functional/test_allocation.py b/placement/tests/functional/test_allocation.py index f48c22df4..439f91760 100644 --- a/placement/tests/functional/test_allocation.py +++ b/placement/tests/functional/test_allocation.py @@ -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() diff --git a/placement/tests/unit/policy_fixture.py b/placement/tests/unit/policy_fixture.py index 6de5bc4b5..5b77b3a6b 100644 --- a/placement/tests/unit/policy_fixture.py +++ b/placement/tests/unit/policy_fixture.py @@ -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') diff --git a/placement/tests/unit/test_policy.py b/placement/tests/unit/test_policy.py index 227f7d98a..db15688e2 100644 --- a/placement/tests/unit/test_policy.py +++ b/placement/tests/unit/test_policy.py @@ -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()