diff --git a/doc/source/developing.rst b/doc/source/developing.rst index 95a04073fa..c5092cc075 100644 --- a/doc/source/developing.rst +++ b/doc/source/developing.rst @@ -173,3 +173,37 @@ or .. code-block:: bash $ pip install -e . + +Standardize Import Format +========================= + +.. _`Import Order Guide`: http://docs.openstack.org/developer/hacking/#imports + +The import order shows below: + +* {{stdlib imports in human alphabetical order}} +* \n +* {{third-party lib imports in human alphabetical order}} +* \n +* {{project imports in human alphabetical order}} +* \n +* \n +* {{begin your code}} + +Example +~~~~~~~ + +.. code-block:: python + + import copy + import fixtures + import mock + import os + + from osc_lib.api import auth + from osc_lib import utils + import six + + from openstackclient import shell + from openstackclient.tests import utils + diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index ae49922ded..faa55118e9 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -17,11 +17,10 @@ import io import logging import os +from osc_lib import utils import six from six.moves import urllib -from osc_lib import utils - from openstackclient.api import api diff --git a/openstackclient/compute/v2/hypervisor_stats.py b/openstackclient/compute/v2/hypervisor_stats.py index a70f0ce1ca..c6fd2992c5 100644 --- a/openstackclient/compute/v2/hypervisor_stats.py +++ b/openstackclient/compute/v2/hypervisor_stats.py @@ -14,9 +14,8 @@ """Hypervisor Stats action implementations""" -import six - from osc_lib.command import command +import six class ShowHypervisorStats(command.ShowOne): diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py index d932b97068..0c609313f9 100644 --- a/openstackclient/identity/client.py +++ b/openstackclient/identity/client.py @@ -21,6 +21,7 @@ from osc_lib import utils from openstackclient.i18n import _ + LOG = logging.getLogger(__name__) DEFAULT_API_VERSION = '3' diff --git a/openstackclient/network/v2/subnet_pool.py b/openstackclient/network/v2/subnet_pool.py index ed2bb0ef05..d3fab8acba 100644 --- a/openstackclient/network/v2/subnet_pool.py +++ b/openstackclient/network/v2/subnet_pool.py @@ -13,7 +13,6 @@ """Subnet pool action implementations""" import copy - import logging from osc_lib.cli import parseractions diff --git a/openstackclient/object/v1/container.py b/openstackclient/object/v1/container.py index 2b021ec25f..f00cc15093 100644 --- a/openstackclient/object/v1/container.py +++ b/openstackclient/object/v1/container.py @@ -15,7 +15,6 @@ """Container v1 action implementations""" - from osc_lib.cli import parseractions from osc_lib.command import command from osc_lib import utils diff --git a/openstackclient/tests/api/fakes.py b/openstackclient/tests/api/fakes.py index e285a61c3c..8d1d88ffc8 100644 --- a/openstackclient/tests/api/fakes.py +++ b/openstackclient/tests/api/fakes.py @@ -13,9 +13,9 @@ """API Test Fakes""" +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.tests import utils diff --git a/openstackclient/tests/api/test_image_v1.py b/openstackclient/tests/api/test_image_v1.py index f347975637..f8ad669200 100644 --- a/openstackclient/tests/api/test_image_v1.py +++ b/openstackclient/tests/api/test_image_v1.py @@ -13,9 +13,9 @@ """Image v1 API Library Tests""" +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.api import image_v1 from openstackclient.tests import utils diff --git a/openstackclient/tests/api/test_image_v2.py b/openstackclient/tests/api/test_image_v2.py index 77063997e2..28b0d5803a 100644 --- a/openstackclient/tests/api/test_image_v2.py +++ b/openstackclient/tests/api/test_image_v2.py @@ -13,9 +13,9 @@ """Image v2 API Library Tests""" +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.api import image_v2 from openstackclient.tests import utils diff --git a/openstackclient/tests/api/test_object_store_v1.py b/openstackclient/tests/api/test_object_store_v1.py index 8cc3a92717..e6ac203d10 100644 --- a/openstackclient/tests/api/test_object_store_v1.py +++ b/openstackclient/tests/api/test_object_store_v1.py @@ -15,9 +15,9 @@ import mock +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.api import object_store_v1 as object_store from openstackclient.tests import utils diff --git a/openstackclient/tests/common/test_availability_zone.py b/openstackclient/tests/common/test_availability_zone.py index feecaf55b3..014ab8bced 100644 --- a/openstackclient/tests/common/test_availability_zone.py +++ b/openstackclient/tests/common/test_availability_zone.py @@ -12,6 +12,7 @@ # import mock + import six from openstackclient.common import availability_zone diff --git a/openstackclient/tests/common/test_extension.py b/openstackclient/tests/common/test_extension.py index 17a3b492dd..10023aa6ac 100644 --- a/openstackclient/tests/common/test_extension.py +++ b/openstackclient/tests/common/test_extension.py @@ -14,12 +14,11 @@ import mock from openstackclient.common import extension -from openstackclient.tests import fakes -from openstackclient.tests import utils - from openstackclient.tests.compute.v2 import fakes as compute_fakes +from openstackclient.tests import fakes from openstackclient.tests.identity.v2_0 import fakes as identity_fakes from openstackclient.tests.network.v2 import fakes as network_fakes +from openstackclient.tests import utils from openstackclient.tests.volume.v2 import fakes as volume_fakes diff --git a/openstackclient/tests/common/test_quota.py b/openstackclient/tests/common/test_quota.py index c9ec5599f1..6f001c8548 100644 --- a/openstackclient/tests/common/test_quota.py +++ b/openstackclient/tests/common/test_quota.py @@ -11,7 +11,6 @@ # under the License. import copy - import mock from openstackclient.common import quota diff --git a/openstackclient/tests/compute/v2/test_agent.py b/openstackclient/tests/compute/v2/test_agent.py index 7695ee4107..07265bb040 100644 --- a/openstackclient/tests/compute/v2/test_agent.py +++ b/openstackclient/tests/compute/v2/test_agent.py @@ -14,8 +14,8 @@ # import mock - from mock import call + from osc_lib import exceptions from openstackclient.compute.v2 import agent diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py index d0cab0191a..786cd6d430 100644 --- a/openstackclient/tests/fakes.py +++ b/openstackclient/tests/fakes.py @@ -15,11 +15,11 @@ import json import mock -import six import sys from keystoneauth1 import fixture import requests +import six AUTH_TOKEN = "foobar" diff --git a/openstackclient/tests/identity/v3/test_identity_provider.py b/openstackclient/tests/identity/v3/test_identity_provider.py index 1ec6105270..b5d784ef32 100644 --- a/openstackclient/tests/identity/v3/test_identity_provider.py +++ b/openstackclient/tests/identity/v3/test_identity_provider.py @@ -13,7 +13,6 @@ # under the License. import copy - import mock from openstackclient.identity.v3 import identity_provider diff --git a/openstackclient/tests/identity/v3/test_mappings.py b/openstackclient/tests/identity/v3/test_mappings.py index 6aa1a6e5db..09a383ebda 100644 --- a/openstackclient/tests/identity/v3/test_mappings.py +++ b/openstackclient/tests/identity/v3/test_mappings.py @@ -13,7 +13,6 @@ # under the License. import copy - import mock from osc_lib import exceptions diff --git a/openstackclient/tests/identity/v3/test_user.py b/openstackclient/tests/identity/v3/test_user.py index c4fb152108..7b99a4cbbc 100644 --- a/openstackclient/tests/identity/v3/test_user.py +++ b/openstackclient/tests/identity/v3/test_user.py @@ -15,7 +15,6 @@ import contextlib import copy - import mock from openstackclient.identity.v3 import user diff --git a/openstackclient/tests/image/v2/test_image.py b/openstackclient/tests/image/v2/test_image.py index c6b83bc5fe..4d9904bb97 100644 --- a/openstackclient/tests/image/v2/test_image.py +++ b/openstackclient/tests/image/v2/test_image.py @@ -16,11 +16,10 @@ import copy import mock -import warlock - from glanceclient.v2 import schemas from osc_lib import exceptions from osc_lib import utils as common_utils +import warlock from openstackclient.image.v2 import image from openstackclient.tests import fakes diff --git a/openstackclient/tests/network/v2/test_address_scope.py b/openstackclient/tests/network/v2/test_address_scope.py index 502516f984..342cf49b11 100644 --- a/openstackclient/tests/network/v2/test_address_scope.py +++ b/openstackclient/tests/network/v2/test_address_scope.py @@ -12,8 +12,8 @@ # import mock - from mock import call + from osc_lib import exceptions from openstackclient.network.v2 import address_scope diff --git a/openstackclient/tests/object/v1/fakes.py b/openstackclient/tests/object/v1/fakes.py index b9e86db759..6c36711127 100644 --- a/openstackclient/tests/object/v1/fakes.py +++ b/openstackclient/tests/object/v1/fakes.py @@ -14,6 +14,7 @@ # from keystoneauth1 import session + from openstackclient.api import object_store_v1 as object_store from openstackclient.tests import utils diff --git a/openstackclient/tests/utils.py b/openstackclient/tests/utils.py index 8dead71840..f3ab5ea63b 100644 --- a/openstackclient/tests/utils.py +++ b/openstackclient/tests/utils.py @@ -14,9 +14,8 @@ # under the License. # -import os - import fixtures +import os import testtools from openstackclient.tests import fakes diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py index ea0c441c69..11f20673da 100644 --- a/openstackclient/volume/client.py +++ b/openstackclient/volume/client.py @@ -19,6 +19,7 @@ from osc_lib import utils from openstackclient.i18n import _ + LOG = logging.getLogger(__name__) DEFAULT_API_VERSION = '2'