diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 44e5c685..a2972973 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,23 +6,36 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: + # whitespace - id: trailing-whitespace - id: mixed-line-ending args: ['--fix', 'lf'] exclude: '.*\.(svg)$' - id: fix-byte-order-marker + # file format and permissions - id: check-executables-have-shebangs - - id: check-merge-conflict + - id: check-shebang-scripts-are-executable - id: debug-statements - id: check-yaml files: .*\.(yaml|yml)$ - - repo: local + - id: check-json + files: .*\.json$ + exclude: .*-curl.*\.json$ + - id: check-ast + # git + - id: check-added-large-files + - id: check-case-conflict + - id: detect-private-key + - id: check-merge-conflict + exclude: '.*\.(rst|inc)$' + - repo: https://github.com/hhatto/autopep8 + rev: v2.3.2 hooks: - - id: flake8 - name: flake8 - additional_dependencies: - - hacking>=3.0.1,<3.1.0 - language: python - entry: flake8 + - id: autopep8 files: '^.*\.py$' + - repo: https://opendev.org/openstack/hacking + rev: 7.0.0 + hooks: + - id: hacking + additional_dependencies: [] exclude: '^(doc|releasenotes|tools)/.*$' diff --git a/cyborg/accelerator/drivers/pci/devspec.py b/cyborg/accelerator/drivers/pci/devspec.py index 91ad68a7..565f60d3 100644 --- a/cyborg/accelerator/drivers/pci/devspec.py +++ b/cyborg/accelerator/drivers/pci/devspec.py @@ -71,6 +71,7 @@ class PhysicalPciAddress(PciAddressSpec): This function class will validate the address fields for a single PCI device. """ + def __init__(self, pci_addr): try: if isinstance(pci_addr, dict): @@ -147,6 +148,7 @@ class PciAddressRegexSpec(PciAddressSpec): The validation includes check for all PCI address attributes and validate their regex. """ + def __init__(self, pci_addr): try: self.domain = pci_addr.get('domain', REGEX_ANY) @@ -188,6 +190,7 @@ class WhitelistPciAddress(object): | passthrough_whitelist = {"vendor_id":"1137","product_id":"0071"} """ + def __init__(self, pci_addr, is_physical_function): self.is_physical_function = is_physical_function self._init_address_fields(pci_addr) diff --git a/cyborg/api/middleware/auth_token.py b/cyborg/api/middleware/auth_token.py index ab445d2c..74c4d10a 100644 --- a/cyborg/api/middleware/auth_token.py +++ b/cyborg/api/middleware/auth_token.py @@ -33,6 +33,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol): for public routes in the API. """ + def __init__(self, app, conf, public_api_routes=None): public_api_routes = public_api_routes or [] self.app = app diff --git a/cyborg/api/middleware/parsable_error.py b/cyborg/api/middleware/parsable_error.py index 2a52b0fe..563980be 100644 --- a/cyborg/api/middleware/parsable_error.py +++ b/cyborg/api/middleware/parsable_error.py @@ -25,6 +25,7 @@ from oslo_serialization import jsonutils class ParsableErrorMiddleware(object): """Replace error body with something the client can parse.""" + def __init__(self, app): self.app = app diff --git a/cyborg/tests/unit/accelerator/drivers/fpga/intel/prepare_test_data.py b/cyborg/tests/unit/accelerator/drivers/fpga/intel/prepare_test_data.py old mode 100755 new mode 100644 index 68bd548c..e1093850 --- a/cyborg/tests/unit/accelerator/drivers/fpga/intel/prepare_test_data.py +++ b/cyborg/tests/unit/accelerator/drivers/fpga/intel/prepare_test_data.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright 2018 Intel, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/cyborg/tests/unit/accelerator/drivers/nic/intel/prepare_test_data.py b/cyborg/tests/unit/accelerator/drivers/nic/intel/prepare_test_data.py index 49a133f6..9ef91e93 100644 --- a/cyborg/tests/unit/accelerator/drivers/nic/intel/prepare_test_data.py +++ b/cyborg/tests/unit/accelerator/drivers/nic/intel/prepare_test_data.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright 2021 Intel, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/devstack/lib/cyborg b/devstack/lib/cyborg index 631f6704..163e7abd 100644 --- a/devstack/lib/cyborg +++ b/devstack/lib/cyborg @@ -1,5 +1,3 @@ -#!/bin/bash -# # lib/cyborg # Functions to control the configuration and operation of the **Cyborg** service @@ -286,4 +284,3 @@ function cyborg_configure_tempest { # Restore xtrace + pipefail $_XTRACE_CYBORG $_PIPEFAIL_CYBORG - diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 041271a1..5e5316a1 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -1,4 +1,3 @@ -#!/bin/bash # plugin.sh - devstack plugin for cyborg # devstack plugin contract defined at: diff --git a/tools/flake8wrap.sh b/tools/flake8wrap.sh old mode 100644 new mode 100755