From af3b7e413483c1739d50a62479ff3f3c9f3eee90 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sat, 19 Aug 2017 07:15:38 +0000 Subject: [PATCH] flake8-import-order: Ensure to place project imports last To ensure project imports are placed after third party import, we need to specify application-import-names. Previously flake8-import-check checks only standard imports or not. Change-Id: I9beb2105f686dc7d9aebfce8e21c5e182698e2fe --- horizon/test/tests/views.py | 7 +++---- horizon/views.py | 3 +-- openstack_dashboard/api/base.py | 5 ++--- openstack_dashboard/api/rest/nova.py | 3 +-- openstack_dashboard/contrib/developer/form_builder/urls.py | 1 + .../contrib/developer/resource_browser/urls.py | 1 + openstack_dashboard/dashboards/admin/dashboard.py | 4 +--- openstack_dashboard/dashboards/admin/flavors/tests.py | 6 ++---- openstack_dashboard/dashboards/admin/flavors/urls.py | 1 + openstack_dashboard/dashboards/admin/images/urls.py | 1 + openstack_dashboard/dashboards/identity/roles/urls.py | 1 + openstack_dashboard/dashboards/project/api_access/panel.py | 1 + openstack_dashboard/dashboards/project/api_access/urls.py | 1 + .../dashboards/project/floating_ips/panel.py | 1 + .../dashboards/project/images/images/urls.py | 1 + openstack_dashboard/dashboards/project/images/urls.py | 1 + .../dashboards/project/instances/console.py | 3 +-- openstack_dashboard/dashboards/project/networks/tests.py | 5 ++--- .../project/routers/extensions/extraroutes/forms.py | 3 +-- .../dashboards/project/security_groups/panel.py | 1 + .../dashboards/project/security_groups/tables.py | 2 +- .../dashboards/project/security_groups/urls.py | 1 + .../dashboards/project/security_groups/views.py | 3 +-- openstack_dashboard/dashboards/project/stacks/tables.py | 3 +-- openstack_dashboard/dashboards/project/stacks/tests.py | 6 ++---- .../integration_tests/pages/admin/system/flavorspage.py | 4 ++-- tox.ini | 3 +++ 27 files changed, 36 insertions(+), 36 deletions(-) diff --git a/horizon/test/tests/views.py b/horizon/test/tests/views.py index 86b5e5c9df..b22b9ababc 100644 --- a/horizon/test/tests/views.py +++ b/horizon/test/tests/views.py @@ -12,15 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. - -from horizon.test import helpers as test -from horizon import views - from django import forms from django.test import client from django.utils.translation import ugettext_lazy as _ from django.views import generic +from horizon.test import helpers as test +from horizon import views + FAKENAME = "FakeName" diff --git a/horizon/views.py b/horizon/views.py index 19b73cd3a5..1e48d83d92 100644 --- a/horizon/views.py +++ b/horizon/views.py @@ -17,12 +17,11 @@ from django import shortcuts from django import template from django.utils import encoding from django.views import generic +from osprofiler import profiler import horizon from horizon import exceptions -from osprofiler import profiler - class PageTitleMixin(object): """A mixin that renders out a page title into a view. diff --git a/openstack_dashboard/api/base.py b/openstack_dashboard/api/base.py index 5bcec0cc96..b7526b251d 100644 --- a/openstack_dashboard/api/base.py +++ b/openstack_dashboard/api/base.py @@ -20,12 +20,11 @@ from collections import Sequence import functools from django.conf import settings - -from horizon import exceptions - import semantic_version import six +from horizon import exceptions + __all__ = ('APIResourceWrapper', 'APIDictWrapper', 'get_service_from_catalog', 'url_for',) diff --git a/openstack_dashboard/api/rest/nova.py b/openstack_dashboard/api/rest/nova.py index 7b0e3c3121..357d7c03c9 100644 --- a/openstack_dashboard/api/rest/nova.py +++ b/openstack_dashboard/api/rest/nova.py @@ -17,11 +17,10 @@ from collections import OrderedDict from django.utils import http as utils_http from django.utils.translation import ugettext_lazy as _ from django.views import generic +from novaclient import exceptions from horizon import exceptions as hz_exceptions -from novaclient import exceptions - from openstack_dashboard import api from openstack_dashboard.api.rest import json_encoder from openstack_dashboard.api.rest import urls diff --git a/openstack_dashboard/contrib/developer/form_builder/urls.py b/openstack_dashboard/contrib/developer/form_builder/urls.py index 7f24dfa2c4..d74763b1b7 100644 --- a/openstack_dashboard/contrib/developer/form_builder/urls.py +++ b/openstack_dashboard/contrib/developer/form_builder/urls.py @@ -13,6 +13,7 @@ # limitations under the License. from django.conf.urls import url + from openstack_dashboard.contrib.developer.form_builder import views urlpatterns = [ diff --git a/openstack_dashboard/contrib/developer/resource_browser/urls.py b/openstack_dashboard/contrib/developer/resource_browser/urls.py index 339174a850..05137b9800 100644 --- a/openstack_dashboard/contrib/developer/resource_browser/urls.py +++ b/openstack_dashboard/contrib/developer/resource_browser/urls.py @@ -13,6 +13,7 @@ # under the License. from django.conf.urls import url + from horizon.browsers.views import AngularIndexView urlpatterns = [ diff --git a/openstack_dashboard/dashboards/admin/dashboard.py b/openstack_dashboard/dashboards/admin/dashboard.py index 7251efa95b..a1eb5feb2f 100644 --- a/openstack_dashboard/dashboards/admin/dashboard.py +++ b/openstack_dashboard/dashboards/admin/dashboard.py @@ -12,14 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. +from django.conf import settings from django.utils.translation import ugettext_lazy as _ - from openstack_auth import utils import horizon -from django.conf import settings - class Admin(horizon.Dashboard): name = _("Admin") diff --git a/openstack_dashboard/dashboards/admin/flavors/tests.py b/openstack_dashboard/dashboards/admin/flavors/tests.py index 27b791939b..a747803f0b 100644 --- a/openstack_dashboard/dashboards/admin/flavors/tests.py +++ b/openstack_dashboard/dashboards/admin/flavors/tests.py @@ -15,15 +15,13 @@ from django.conf import settings from django.core.urlresolvers import reverse from django import http from mox3.mox import IsA - -from openstack_dashboard import api -from openstack_dashboard.test import helpers as test - from novaclient.v2 import flavors +from openstack_dashboard import api from openstack_dashboard.dashboards.admin.flavors import constants from openstack_dashboard.dashboards.admin.flavors import tables from openstack_dashboard.dashboards.admin.flavors import workflows +from openstack_dashboard.test import helpers as test class FlavorsViewTests(test.BaseAdminViewTests): diff --git a/openstack_dashboard/dashboards/admin/flavors/urls.py b/openstack_dashboard/dashboards/admin/flavors/urls.py index b3d0b243cf..88ecfe6cfc 100644 --- a/openstack_dashboard/dashboards/admin/flavors/urls.py +++ b/openstack_dashboard/dashboards/admin/flavors/urls.py @@ -19,6 +19,7 @@ from django.conf import settings from django.conf.urls import url from django.utils.translation import ugettext_lazy as _ + from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.admin.flavors import views diff --git a/openstack_dashboard/dashboards/admin/images/urls.py b/openstack_dashboard/dashboards/admin/images/urls.py index 6d75d5c70f..1464f37bae 100644 --- a/openstack_dashboard/dashboards/admin/images/urls.py +++ b/openstack_dashboard/dashboards/admin/images/urls.py @@ -19,6 +19,7 @@ from django.conf import settings from django.conf.urls import url from django.utils.translation import ugettext_lazy as _ + from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.admin.images import views diff --git a/openstack_dashboard/dashboards/identity/roles/urls.py b/openstack_dashboard/dashboards/identity/roles/urls.py index 4de1216fec..f7a4451f27 100644 --- a/openstack_dashboard/dashboards/identity/roles/urls.py +++ b/openstack_dashboard/dashboards/identity/roles/urls.py @@ -15,6 +15,7 @@ from django.conf import settings from django.conf.urls import url from django.utils.translation import ugettext_lazy as _ + from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.identity.roles import views diff --git a/openstack_dashboard/dashboards/project/api_access/panel.py b/openstack_dashboard/dashboards/project/api_access/panel.py index f8e01fb7ba..947c19b7e9 100644 --- a/openstack_dashboard/dashboards/project/api_access/panel.py +++ b/openstack_dashboard/dashboards/project/api_access/panel.py @@ -13,6 +13,7 @@ # under the License. from django.utils.translation import ugettext_lazy as _ + import horizon diff --git a/openstack_dashboard/dashboards/project/api_access/urls.py b/openstack_dashboard/dashboards/project/api_access/urls.py index cbcee5bbcd..b7b1810c9f 100644 --- a/openstack_dashboard/dashboards/project/api_access/urls.py +++ b/openstack_dashboard/dashboards/project/api_access/urls.py @@ -17,6 +17,7 @@ # under the License. from django.conf.urls import url + from openstack_dashboard.dashboards.project.api_access import views urlpatterns = [ diff --git a/openstack_dashboard/dashboards/project/floating_ips/panel.py b/openstack_dashboard/dashboards/project/floating_ips/panel.py index e813be28d9..307a563de4 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/panel.py +++ b/openstack_dashboard/dashboards/project/floating_ips/panel.py @@ -14,6 +14,7 @@ from django.conf import settings from django.utils.translation import ugettext_lazy as _ + import horizon diff --git a/openstack_dashboard/dashboards/project/images/images/urls.py b/openstack_dashboard/dashboards/project/images/images/urls.py index 68b3962bc2..b82efeed94 100644 --- a/openstack_dashboard/dashboards/project/images/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/images/urls.py @@ -19,6 +19,7 @@ from django.conf import settings from django.conf.urls import url from django.utils.translation import ugettext_lazy as _ + from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.project.images.images import views diff --git a/openstack_dashboard/dashboards/project/images/urls.py b/openstack_dashboard/dashboards/project/images/urls.py index c0bf79c28f..88ae3e05aa 100644 --- a/openstack_dashboard/dashboards/project/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/urls.py @@ -20,6 +20,7 @@ from django.conf import settings from django.conf.urls import include from django.conf.urls import url from django.utils.translation import ugettext_lazy as _ + from horizon.browsers.views import AngularIndexView from openstack_dashboard.dashboards.project.images.images \ import urls as image_urls diff --git a/openstack_dashboard/dashboards/project/instances/console.py b/openstack_dashboard/dashboards/project/instances/console.py index ca2e5a7b1a..9380889256 100644 --- a/openstack_dashboard/dashboards/project/instances/console.py +++ b/openstack_dashboard/dashboards/project/instances/console.py @@ -16,11 +16,10 @@ import logging from django.utils.http import urlencode from django.utils.translation import ugettext_lazy as _ +from novaclient import exceptions as nova_exception from horizon import exceptions -from novaclient import exceptions as nova_exception - from openstack_dashboard import api LOG = logging.getLogger(__name__) diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py index 17a94ff87c..54739404a4 100644 --- a/openstack_dashboard/dashboards/project/networks/tests.py +++ b/openstack_dashboard/dashboards/project/networks/tests.py @@ -16,12 +16,11 @@ from django.core.urlresolvers import reverse from django import http from django.utils.html import escape from django.utils.http import urlunquote - -from horizon.workflows import views - from mox3.mox import IsA import six +from horizon.workflows import views + from openstack_dashboard import api from openstack_dashboard.dashboards.project.networks import tables\ as networks_tables diff --git a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py index 2345f2fe92..bf8001dbf0 100644 --- a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py +++ b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py @@ -17,13 +17,12 @@ import logging from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +from neutronclient.common import exceptions as neutron_exc from horizon import exceptions from horizon import forms from horizon import messages -from neutronclient.common import exceptions as neutron_exc - from openstack_dashboard.api import neutron as api LOG = logging.getLogger(__name__) diff --git a/openstack_dashboard/dashboards/project/security_groups/panel.py b/openstack_dashboard/dashboards/project/security_groups/panel.py index cde9894fdf..b8378841ec 100644 --- a/openstack_dashboard/dashboards/project/security_groups/panel.py +++ b/openstack_dashboard/dashboards/project/security_groups/panel.py @@ -13,6 +13,7 @@ # under the License. from django.utils.translation import ugettext_lazy as _ + import horizon diff --git a/openstack_dashboard/dashboards/project/security_groups/tables.py b/openstack_dashboard/dashboards/project/security_groups/tables.py index 18add4f867..1f8f0ecac8 100644 --- a/openstack_dashboard/dashboards/project/security_groups/tables.py +++ b/openstack_dashboard/dashboards/project/security_groups/tables.py @@ -16,9 +16,9 @@ from django.conf import settings from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy +import six from horizon import tables -import six from openstack_dashboard import api from openstack_dashboard import policy diff --git a/openstack_dashboard/dashboards/project/security_groups/urls.py b/openstack_dashboard/dashboards/project/security_groups/urls.py index 0dc4a2a809..fc1e77a2d2 100644 --- a/openstack_dashboard/dashboards/project/security_groups/urls.py +++ b/openstack_dashboard/dashboards/project/security_groups/urls.py @@ -17,6 +17,7 @@ # under the License. from django.conf.urls import url + from openstack_dashboard.dashboards.project.security_groups import views urlpatterns = [ diff --git a/openstack_dashboard/dashboards/project/security_groups/views.py b/openstack_dashboard/dashboards/project/security_groups/views.py index 6750025a17..292c89ff59 100644 --- a/openstack_dashboard/dashboards/project/security_groups/views.py +++ b/openstack_dashboard/dashboards/project/security_groups/views.py @@ -22,14 +22,13 @@ Views for managing instances. from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ +from neutronclient.common import exceptions as neutron_exc from horizon import exceptions from horizon import forms from horizon import tables from horizon.utils import memoized -from neutronclient.common import exceptions as neutron_exc - from openstack_dashboard import api from openstack_dashboard.dashboards.project.security_groups \ import forms as project_forms diff --git a/openstack_dashboard/dashboards/project/stacks/tables.py b/openstack_dashboard/dashboards/project/stacks/tables.py index 4de0766892..8159b2b5e2 100644 --- a/openstack_dashboard/dashboards/project/stacks/tables.py +++ b/openstack_dashboard/dashboards/project/stacks/tables.py @@ -16,14 +16,13 @@ from django.template.defaultfilters import title from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy +from heatclient import exc from horizon import exceptions from horizon import messages from horizon import tables from horizon.utils import filters -from heatclient import exc - from openstack_dashboard import api from openstack_dashboard.dashboards.project.stacks import mappings diff --git a/openstack_dashboard/dashboards/project/stacks/tests.py b/openstack_dashboard/dashboards/project/stacks/tests.py index b605d011db..d646a51d15 100644 --- a/openstack_dashboard/dashboards/project/stacks/tests.py +++ b/openstack_dashboard/dashboards/project/stacks/tests.py @@ -20,18 +20,16 @@ from django.core.urlresolvers import reverse from django import http from django.test.utils import override_settings from django.utils import html - +from heatclient.common import template_format as hc_format from mox3.mox import IsA import six -from heatclient.common import template_format as hc_format from openstack_dashboard import api -from openstack_dashboard.test import helpers as test - from openstack_dashboard.dashboards.project.stacks import api as project_api from openstack_dashboard.dashboards.project.stacks import forms from openstack_dashboard.dashboards.project.stacks import mappings from openstack_dashboard.dashboards.project.stacks import tables +from openstack_dashboard.test import helpers as test INDEX_TEMPLATE = 'horizon/common/_data_table_view.html' diff --git a/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py b/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py index 70da247248..18cea535c4 100644 --- a/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py +++ b/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py @@ -10,13 +10,13 @@ # License for the specific language governing permissions and limitations # under the License. +from selenium.webdriver.common import by + from openstack_dashboard.test.integration_tests.pages import basepage from openstack_dashboard.test.integration_tests.regions import forms from openstack_dashboard.test.integration_tests.regions import menus from openstack_dashboard.test.integration_tests.regions import tables -from selenium.webdriver.common import by - class FlavorsTable(tables.TableRegion): name = "flavors" diff --git a/tox.ini b/tox.ini index 9a030bc611..a7c53bfe18 100644 --- a/tox.ini +++ b/tox.ini @@ -143,7 +143,10 @@ ignore = # H904 Delay string interpolations at logging calls enable-extensions=H203,H904 max-complexity = 20 + +# flake8-import-order configurations import-order-style = pep8 +application-import-names = horizon,openstack_dashboard [hacking] local-check-factory = horizon.hacking.checks.factory