Use hacking for pep8 tests

Enforce flake8 checks based on Openstack StyleGuide using the
hacking module.
Also enforce check for pep8 module import style.

Change-Id: I1ff39f402d12e2c921705d265dcae5b6c5f70aa3
This commit is contained in:
Riccardo Pittau 2020-04-06 10:12:08 +02:00
parent d2e7fa7fe2
commit 1921ecfb46
14 changed files with 56 additions and 27 deletions

View File

@ -14,7 +14,11 @@ import configparser
import logging import logging
import os import os
from flask import abort, Flask, Response from flask import abort
from flask import Flask
from flask import Response
application = Flask(__name__) application = Flask(__name__)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,12 +13,15 @@
import logging import logging
import os import os
from ironic_prometheus_exporter.parsers import ipmi
from ironic_prometheus_exporter.parsers import header
from ironic_prometheus_exporter.parsers import redfish
from oslo_config import cfg from oslo_config import cfg
from oslo_messaging.notify import notifier from oslo_messaging.notify import notifier
from prometheus_client import write_to_textfile, CollectorRegistry from prometheus_client import CollectorRegistry
from prometheus_client import write_to_textfile
from ironic_prometheus_exporter.parsers import header
from ironic_prometheus_exporter.parsers import ipmi
from ironic_prometheus_exporter.parsers import redfish
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,7 @@
import json import json
import logging import logging
import os import os
import pkg_resources import pkg_resources
DESCRIPTIONS = {} DESCRIPTIONS = {}

View File

@ -14,8 +14,8 @@ from datetime import datetime
from prometheus_client import Gauge from prometheus_client import Gauge
from ironic_prometheus_exporter import utils as ipe_utils
from ironic_prometheus_exporter.parsers import descriptions from ironic_prometheus_exporter.parsers import descriptions
from ironic_prometheus_exporter import utils as ipe_utils
def timestamp_registry(node_information, ipmi_metric_registry): def timestamp_registry(node_information, ipmi_metric_registry):

View File

@ -12,13 +12,13 @@
import json import json
import logging import logging
import pkg_resources
import re import re
import pkg_resources
from prometheus_client import Gauge from prometheus_client import Gauge
from ironic_prometheus_exporter import utils as ipe_utils
from ironic_prometheus_exporter.parsers import descriptions from ironic_prometheus_exporter.parsers import descriptions
from ironic_prometheus_exporter import utils as ipe_utils
# NOTE (iurygregory): most of the sensor readings come in the ipmi format # NOTE (iurygregory): most of the sensor readings come in the ipmi format
@ -140,7 +140,7 @@ def metric_names(category_info):
def extract_labels(entries, category_info): def extract_labels(entries, category_info):
""" This function extract the labels to be used by a metric """This function extract the labels to be used by a metric
If a metric has many entries we add the 'Sensor ID' information as label If a metric has many entries we add the 'Sensor ID' information as label
otherwise we will only use the default label that is the 'node_name' and otherwise we will only use the default label that is the 'node_name' and

View File

@ -15,8 +15,8 @@ import logging
from prometheus_client import Gauge from prometheus_client import Gauge
from ironic_prometheus_exporter import utils as ipe_utils
from ironic_prometheus_exporter.parsers import descriptions from ironic_prometheus_exporter.parsers import descriptions
from ironic_prometheus_exporter import utils as ipe_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from ironic_prometheus_exporter.parsers import descriptions
from oslo_messaging.tests import utils as test_utils from oslo_messaging.tests import utils as test_utils
from ironic_prometheus_exporter.parsers import descriptions
class TestMetricsDescriptions(test_utils.BaseTestCase): class TestMetricsDescriptions(test_utils.BaseTestCase):

View File

@ -10,14 +10,15 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import fixtures
import json import json
import os import os
import fixtures
import oslo_messaging import oslo_messaging
from oslo_messaging.tests import utils as test_utils
import ironic_prometheus_exporter import ironic_prometheus_exporter
from ironic_prometheus_exporter.messaging import PrometheusFileDriver from ironic_prometheus_exporter.messaging import PrometheusFileDriver
from oslo_messaging.tests import utils as test_utils
class TestPrometheusFileNotifier(test_utils.BaseTestCase): class TestPrometheusFileNotifier(test_utils.BaseTestCase):

View File

@ -14,11 +14,12 @@ import json
import os import os
import unittest import unittest
import ironic_prometheus_exporter
from ironic_prometheus_exporter import utils as ipe_utils
from ironic_prometheus_exporter.parsers import header
from prometheus_client import CollectorRegistry from prometheus_client import CollectorRegistry
import ironic_prometheus_exporter
from ironic_prometheus_exporter.parsers import header
from ironic_prometheus_exporter import utils as ipe_utils
sample_file = os.path.join( sample_file = os.path.join(
os.path.dirname(ironic_prometheus_exporter.__file__), os.path.dirname(ironic_prometheus_exporter.__file__),

View File

@ -14,11 +14,12 @@ import json
import os import os
import unittest import unittest
import ironic_prometheus_exporter
from ironic_prometheus_exporter import utils as ipe_utils
from ironic_prometheus_exporter.parsers import ipmi
from prometheus_client import CollectorRegistry from prometheus_client import CollectorRegistry
import ironic_prometheus_exporter
from ironic_prometheus_exporter.parsers import ipmi
from ironic_prometheus_exporter import utils as ipe_utils
sample_file = os.path.join( sample_file = os.path.join(
os.path.dirname(ironic_prometheus_exporter.__file__), os.path.dirname(ironic_prometheus_exporter.__file__),

View File

@ -1,12 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json import json
import os import os
import unittest import unittest
import ironic_prometheus_exporter
from ironic_prometheus_exporter import utils as ipe_utils
from ironic_prometheus_exporter.parsers import redfish
from prometheus_client import CollectorRegistry from prometheus_client import CollectorRegistry
import ironic_prometheus_exporter
from ironic_prometheus_exporter.parsers import redfish
from ironic_prometheus_exporter import utils as ipe_utils
sample_file = os.path.join( sample_file = os.path.join(
os.path.dirname(ironic_prometheus_exporter.__file__), os.path.dirname(ironic_prometheus_exporter.__file__),

View File

@ -23,6 +23,7 @@ Flask==1.0.0
future==0.18.2 future==0.18.2
futurist==2.1.0 futurist==2.1.0
greenlet==0.4.15 greenlet==0.4.15
hacking==3.0.0
idna==2.9 idna==2.9
importlib-metadata==1.6.0 importlib-metadata==1.6.0
iso8601==0.1.12 iso8601==0.1.12

View File

@ -1,3 +1,6 @@
hacking>=3.0.0,<3.1.0 # Apache-2.0
flake8 flake8
flake8-import-order>=0.17.1
stestr>=2.0.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0

View File

@ -54,10 +54,11 @@ deps =
commands = {posargs} commands = {posargs}
[flake8] [flake8]
ignore = E129 application-import-names = ironic_prometheus_exporter
show-source = True
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
import-order-style = pep8
show-source = True
[testenv:lower-constraints] [testenv:lower-constraints]
deps = deps =