From f4c0468b3667f4a967e2a0402c0f49dcca55e29f Mon Sep 17 00:00:00 2001 From: Cao Xuan Hoang Date: Thu, 6 Jul 2017 09:05:14 +0700 Subject: [PATCH] Use flake8-import-order plugin In reviews we usually check import grouping but it is boring. By using flake8-import-order plugin, we can avoid this. It enforces loose checking so it sounds good to use it. This flake8 plugin is already used in tempest. Note that flake8-import-order version is pinned to avoid unexpected breakage of pep8 job. Setup for unit tests of hacking rules is tweaked to disable flake8-import-order checks. This extension assumes an actual file exists and causes hacking rule unit tests. Change-Id: I61e683ab0119e4ae90b7107f0690528d789e3875 --- neutronclient/neutron/v2_0/auto_allocated_topology.py | 1 + neutronclient/tests/unit/osc/v2/fakes.py | 2 +- neutronclient/tests/unit/osc/v2/fwaas/fakes.py | 3 ++- neutronclient/tests/unit/osc/v2/fwaas/test_firewallgroup.py | 2 +- neutronclient/tests/unit/osc/v2/fwaas/test_firewallpolicy.py | 2 +- neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py | 4 ++-- neutronclient/tests/unit/osc/v2/networking_bgpvpn/fakes.py | 1 + .../tests/unit/osc/v2/networking_bgpvpn/test_bgpvpn.py | 2 +- .../osc/v2/networking_bgpvpn/test_resource_association.py | 2 +- neutronclient/tests/unit/osc/v2/trunk/fakes.py | 3 ++- neutronclient/tests/unit/osc/v2/trunk/test_network_trunk.py | 4 ++-- test-requirements.txt | 1 + tox.ini | 2 ++ 13 files changed, 18 insertions(+), 11 deletions(-) diff --git a/neutronclient/neutron/v2_0/auto_allocated_topology.py b/neutronclient/neutron/v2_0/auto_allocated_topology.py index 12ca4dbd1..ef0da4325 100644 --- a/neutronclient/neutron/v2_0/auto_allocated_topology.py +++ b/neutronclient/neutron/v2_0/auto_allocated_topology.py @@ -17,6 +17,7 @@ from __future__ import print_function import argparse + from cliff import show from oslo_serialization import jsonutils diff --git a/neutronclient/tests/unit/osc/v2/fakes.py b/neutronclient/tests/unit/osc/v2/fakes.py index cc30842ab..afa81e72d 100644 --- a/neutronclient/tests/unit/osc/v2/fakes.py +++ b/neutronclient/tests/unit/osc/v2/fakes.py @@ -12,9 +12,9 @@ # import argparse -import mock from cliff import columns as cliff_columns +import mock from osc_lib.tests import utils diff --git a/neutronclient/tests/unit/osc/v2/fwaas/fakes.py b/neutronclient/tests/unit/osc/v2/fwaas/fakes.py index 7a22ab1ab..7baef8421 100644 --- a/neutronclient/tests/unit/osc/v2/fwaas/fakes.py +++ b/neutronclient/tests/unit/osc/v2/fwaas/fakes.py @@ -16,9 +16,10 @@ import collections import copy -import mock import uuid +import mock + class FakeFWaaS(object): diff --git a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallgroup.py b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallgroup.py index 0a15f2b6d..87fb4c2fd 100644 --- a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallgroup.py +++ b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallgroup.py @@ -15,9 +15,9 @@ # import copy -import mock import re +import mock from osc_lib import exceptions from osc_lib.tests import utils diff --git a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallpolicy.py b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallpolicy.py index 6d9780768..c2e9b1bb9 100644 --- a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallpolicy.py +++ b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallpolicy.py @@ -15,9 +15,9 @@ # import copy -import mock import re +import mock from osc_lib import exceptions from osc_lib.tests import utils diff --git a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py index d09bbbe98..94e119940 100644 --- a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py +++ b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py @@ -15,12 +15,12 @@ # import copy -import mock import re -import testtools +import mock from osc_lib import exceptions from osc_lib.tests import utils +import testtools from neutronclient.osc import utils as osc_utils from neutronclient.osc.v2.fwaas import constants as const diff --git a/neutronclient/tests/unit/osc/v2/networking_bgpvpn/fakes.py b/neutronclient/tests/unit/osc/v2/networking_bgpvpn/fakes.py index 6138feaf3..7da3a9850 100644 --- a/neutronclient/tests/unit/osc/v2/networking_bgpvpn/fakes.py +++ b/neutronclient/tests/unit/osc/v2/networking_bgpvpn/fakes.py @@ -15,6 +15,7 @@ # import copy + import mock from neutronclient.osc import utils as nc_osc_utils diff --git a/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_bgpvpn.py b/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_bgpvpn.py index aa688277d..f13980eda 100644 --- a/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_bgpvpn.py +++ b/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_bgpvpn.py @@ -15,9 +15,9 @@ # import copy -import mock import operator +import mock from osc_lib import exceptions from osc_lib import utils as osc_utils diff --git a/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_resource_association.py b/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_resource_association.py index e7bc8ce9c..6978d85cd 100644 --- a/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_resource_association.py +++ b/neutronclient/tests/unit/osc/v2/networking_bgpvpn/test_resource_association.py @@ -15,9 +15,9 @@ # import copy -import mock import operator +import mock from osc_lib import exceptions from osc_lib import utils as osc_utils diff --git a/neutronclient/tests/unit/osc/v2/trunk/fakes.py b/neutronclient/tests/unit/osc/v2/trunk/fakes.py index 4ae1f287f..12f773f03 100644 --- a/neutronclient/tests/unit/osc/v2/trunk/fakes.py +++ b/neutronclient/tests/unit/osc/v2/trunk/fakes.py @@ -11,9 +11,10 @@ # under the License. import copy -import mock import uuid +import mock + class FakeTrunk(object): """Fake one or more trunks.""" diff --git a/neutronclient/tests/unit/osc/v2/trunk/test_network_trunk.py b/neutronclient/tests/unit/osc/v2/trunk/test_network_trunk.py index 8b7aaa0d5..8e9e73c49 100644 --- a/neutronclient/tests/unit/osc/v2/trunk/test_network_trunk.py +++ b/neutronclient/tests/unit/osc/v2/trunk/test_network_trunk.py @@ -15,13 +15,13 @@ import argparse import copy + import mock from mock import call -import testtools - from osc_lib.cli import format_columns from osc_lib import exceptions from osc_lib.tests import utils as tests_utils +import testtools from neutronclient.osc.v2.trunk import network_trunk as trunk from neutronclient.osc.v2 import utils as v2_utils diff --git a/test-requirements.txt b/test-requirements.txt index 85ccf056b..ae2856685 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,6 +5,7 @@ hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD +flake8-import-order==0.12 # LGPLv3 mox3!=0.19.0,>=0.7.0 # Apache-2.0 mock>=2.0 # BSD openstackdocstheme>=1.11.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 587612486..23fda5012 100644 --- a/tox.ini +++ b/tox.ini @@ -55,5 +55,7 @@ commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenote [flake8] show-source = true exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools +import-order-style = pep8 + # H904: Delay string interpolations at logging calls enable-extensions=H904