diff --git a/proliantutils/ilo/client.py b/proliantutils/ilo/client.py index 1aa4f709..ef3bd4ee 100644 --- a/proliantutils/ilo/client.py +++ b/proliantutils/ilo/client.py @@ -11,10 +11,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + """IloClient module""" import collections + import netaddr + from proliantutils import exception from proliantutils.ilo import ipmi from proliantutils.ilo import operations @@ -24,6 +27,7 @@ from proliantutils.ilo.snmp import snmp_cpqdisk_sizes as snmp from proliantutils import log from proliantutils.redfish import redfish + SUPPORTED_RIS_METHODS = [ 'activate_license', 'clear_secure_boot_keys', diff --git a/proliantutils/ilo/ris.py b/proliantutils/ilo/ris.py index 68373967..bb7324bc 100755 --- a/proliantutils/ilo/ris.py +++ b/proliantutils/ilo/ris.py @@ -15,6 +15,7 @@ __author__ = 'HPE' import hashlib + import retrying from proliantutils import exception diff --git a/proliantutils/redfish/resources/system/memory.py b/proliantutils/redfish/resources/system/memory.py index 4e32882f..5f2998d9 100644 --- a/proliantutils/redfish/resources/system/memory.py +++ b/proliantutils/redfish/resources/system/memory.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +import collections + from sushy.resources import base -import collections from proliantutils.redfish.resources.system import constants as sys_cons from proliantutils.redfish.resources.system import mappings diff --git a/proliantutils/redfish/resources/system/smart_storage_config.py b/proliantutils/redfish/resources/system/smart_storage_config.py index ce277876..15c595a9 100644 --- a/proliantutils/redfish/resources/system/smart_storage_config.py +++ b/proliantutils/redfish/resources/system/smart_storage_config.py @@ -12,12 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. -from proliantutils import exception -from proliantutils import log from sushy.resources import base +from proliantutils import exception from proliantutils.hpssa import constants from proliantutils.hpssa import manager +from proliantutils import log from proliantutils.redfish.resources.system.storage import \ constants as storage_const from proliantutils.redfish.resources.system.storage import \ diff --git a/proliantutils/redfish/resources/system/storage/array_controller.py b/proliantutils/redfish/resources/system/storage/array_controller.py index 60f62b5d..e2dfa6d5 100644 --- a/proliantutils/redfish/resources/system/storage/array_controller.py +++ b/proliantutils/redfish/resources/system/storage/array_controller.py @@ -14,12 +14,13 @@ import logging +from sushy.resources import base from sushy import utils as sushy_utils from proliantutils.redfish.resources.system.storage import logical_drive from proliantutils.redfish.resources.system.storage import physical_drive from proliantutils.redfish import utils -from sushy.resources import base + LOG = logging.getLogger(__name__) diff --git a/proliantutils/redfish/resources/system/storage/drive.py b/proliantutils/redfish/resources/system/storage/drive.py index c3fe4a8e..6b2f296f 100644 --- a/proliantutils/redfish/resources/system/storage/drive.py +++ b/proliantutils/redfish/resources/system/storage/drive.py @@ -12,14 +12,15 @@ # License for the specific language governing permissions and limitations # under the License. -# There is no explicit collection for Drives. That said, a URI link as -# "/redfish/v1/Systems/1/Storage/1/Drives" will be an invalid URI. - - -from proliantutils.redfish.resources.system.storage import mappings +""" +There is no explicit collection for Drives. That said, a URI link as +"/redfish/v1/Systems/1/Storage/1/Drives" will be an invalid URI. +""" from sushy.resources import base +from proliantutils.redfish.resources.system.storage import mappings + class Drive(base.ResourceBase): """This class represents the Drive resource""" diff --git a/proliantutils/redfish/resources/system/storage/logical_drive.py b/proliantutils/redfish/resources/system/storage/logical_drive.py index 717f875f..742ede66 100644 --- a/proliantutils/redfish/resources/system/storage/logical_drive.py +++ b/proliantutils/redfish/resources/system/storage/logical_drive.py @@ -15,9 +15,8 @@ from sushy.resources import base from sushy import utils as sushy_utils -from proliantutils.redfish import utils - from proliantutils.redfish.resources.system.storage import mappings +from proliantutils.redfish import utils class HPELogicalDrive(base.ResourceBase): diff --git a/proliantutils/redfish/resources/system/storage/physical_drive.py b/proliantutils/redfish/resources/system/storage/physical_drive.py index 3f1c5e02..6217b3d3 100644 --- a/proliantutils/redfish/resources/system/storage/physical_drive.py +++ b/proliantutils/redfish/resources/system/storage/physical_drive.py @@ -15,10 +15,9 @@ from sushy.resources import base from sushy import utils as sushy_utils -from proliantutils.redfish import utils - from proliantutils.redfish.resources.system.storage import constants from proliantutils.redfish.resources.system.storage import mappings +from proliantutils.redfish import utils class HPEPhysicalDrive(base.ResourceBase): diff --git a/proliantutils/redfish/resources/system/system.py b/proliantutils/redfish/resources/system/system.py index 101d77ca..e1776f3b 100644 --- a/proliantutils/redfish/resources/system/system.py +++ b/proliantutils/redfish/resources/system/system.py @@ -15,6 +15,7 @@ __author__ = 'HPE' import re + import sushy from sushy.resources import base from sushy.resources.system import system @@ -38,7 +39,6 @@ from proliantutils.redfish.resources.system.storage import simple_storage from proliantutils.redfish.resources.system.storage import \ smart_storage as hpe_smart_storage from proliantutils.redfish.resources.system.storage import storage - from proliantutils.redfish import utils diff --git a/proliantutils/redfish/resources/update_service.py b/proliantutils/redfish/resources/update_service.py index 733d9d15..0b962e64 100644 --- a/proliantutils/redfish/resources/update_service.py +++ b/proliantutils/redfish/resources/update_service.py @@ -15,7 +15,6 @@ __author__ = 'HPE' import sushy - from sushy.resources import base from sushy.resources import common as sushy_common diff --git a/proliantutils/tests/hpssa/test_manager.py b/proliantutils/tests/hpssa/test_manager.py index 63575812..b1833450 100644 --- a/proliantutils/tests/hpssa/test_manager.py +++ b/proliantutils/tests/hpssa/test_manager.py @@ -12,9 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +import time + import mock import testtools -import time from proliantutils import exception from proliantutils.hpssa import manager diff --git a/proliantutils/tests/ilo/test_ribcl.py b/proliantutils/tests/ilo/test_ribcl.py index 651d5c83..bea11487 100644 --- a/proliantutils/tests/ilo/test_ribcl.py +++ b/proliantutils/tests/ilo/test_ribcl.py @@ -19,13 +19,13 @@ import json import re import unittest import xml.etree.ElementTree as ET -import xmltodict import ddt import mock import requests from requests.packages import urllib3 from requests.packages.urllib3 import exceptions as urllib3_exceptions +import xmltodict from proliantutils import exception from proliantutils.ilo import common diff --git a/proliantutils/tests/ipa_hw_manager/__init__.py b/proliantutils/tests/ipa_hw_manager/__init__.py index abb82992..b23f6ad7 100644 --- a/proliantutils/tests/ipa_hw_manager/__init__.py +++ b/proliantutils/tests/ipa_hw_manager/__init__.py @@ -12,11 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. -import six import sys import mock from oslo_utils import importutils +import six + ironic_python_agent = importutils.try_import('ironic_python_agent') if not ironic_python_agent: diff --git a/proliantutils/tests/redfish/resources/manager/test_manager.py b/proliantutils/tests/redfish/resources/manager/test_manager.py index 104de4f6..15d71dd4 100644 --- a/proliantutils/tests/redfish/resources/manager/test_manager.py +++ b/proliantutils/tests/redfish/resources/manager/test_manager.py @@ -14,6 +14,7 @@ # under the License. import json + import mock import testtools diff --git a/proliantutils/tests/redfish/resources/manager/test_virtual_media.py b/proliantutils/tests/redfish/resources/manager/test_virtual_media.py index 5790fd84..10d3ea61 100644 --- a/proliantutils/tests/redfish/resources/manager/test_virtual_media.py +++ b/proliantutils/tests/redfish/resources/manager/test_virtual_media.py @@ -17,10 +17,9 @@ __author__ = 'HPE' import json import mock -import testtools - from sushy import exceptions from sushy.resources.manager import virtual_media as sushy_virt_media +import testtools from proliantutils import exception from proliantutils.redfish.resources.manager import constants diff --git a/proliantutils/tests/redfish/resources/system/test_system.py b/proliantutils/tests/redfish/resources/system/test_system.py index 5458e591..bc372e9b 100644 --- a/proliantutils/tests/redfish/resources/system/test_system.py +++ b/proliantutils/tests/redfish/resources/system/test_system.py @@ -17,6 +17,7 @@ import json import mock import sushy +from sushy.resources.system import system as sushy_system import testtools from proliantutils import exception @@ -32,7 +33,6 @@ from proliantutils.redfish.resources.system.storage import smart_storage from proliantutils.redfish.resources.system.storage import storage from proliantutils.redfish.resources.system import system from proliantutils.redfish import utils -from sushy.resources.system import system as sushy_system class HPESystemTestCase(testtools.TestCase): diff --git a/proliantutils/tests/redfish/resources/test_update_service.py b/proliantutils/tests/redfish/resources/test_update_service.py index 1728c757..677e1ee0 100644 --- a/proliantutils/tests/redfish/resources/test_update_service.py +++ b/proliantutils/tests/redfish/resources/test_update_service.py @@ -14,10 +14,11 @@ # under the License. import json +import time + import mock import sushy import testtools -import time from proliantutils import exception from proliantutils.ilo import common diff --git a/proliantutils/tests/redfish/test_redfish.py b/proliantutils/tests/redfish/test_redfish.py index 612347d2..2b586990 100644 --- a/proliantutils/tests/redfish/test_redfish.py +++ b/proliantutils/tests/redfish/test_redfish.py @@ -14,14 +14,13 @@ # under the License. import collections +import json import ddt -import json import mock import sushy -import testtools - from sushy.resources.system import system +import testtools from proliantutils import exception from proliantutils.ilo import constants as ilo_cons diff --git a/test-requirements.txt b/test-requirements.txt index a0902270..199a9314 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,7 @@ +# linters +hacking>=3.0.0,<3.1.0 # Apache-2.0 +flake8-import-order>=0.17.1 # LGPLv3 + mock coverage>=3.6 # Apache-2.0 stestr!=2.3.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 57ac91cb..3a356b32 100644 --- a/tox.ini +++ b/tox.ini @@ -22,10 +22,7 @@ commands = passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY [testenv:pep8] -deps = - hacking>=3.0.0,<3.1.0 -commands = - flake8 proliantutils +commands = flake8 {posargs} [testenv:cover] # After running this target, visit proliantutils/cover/index.html @@ -42,14 +39,16 @@ commands = coverage html -d ./cover --omit='*tests*' [flake8] +show-source = True # [C901] function is too complex. # [E731] do not assign a lambda expression, use a def # [W503] Line break occurred before a binary operator. Conflicts with W504. ignore = C901,E731,W503 -# Exclude MIB directories from flake8/pep8 tests as these are -# autogenerated files. -exclude = ./proliantutils/ilo/snmp/cpqdisk_mibs +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,*cpqdisk_mibs max-complexity=15 +import-order-style = pep8 +application-import-names = proliantutils +filename = *.py [testenv:venv] setenv = PYTHONHASHSEED=0