From c022b73faf479346f1d73edf417cb5d8a8f33195 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Wed, 8 Mar 2017 17:50:27 +0100 Subject: [PATCH] Fix pep8 errors There are some PEP8 errors that are not caught by our gate because of the pep8 package version installed by hacking. This patch fixes E402, W503, and F999 erors from our codebase. Change-Id: I0b86730b1493f161645a87c3daa91ec3d774d3b1 --- cinderclient/__init__.py | 5 ++-- cinderclient/client.py | 12 ++++----- cinderclient/shell.py | 36 +++++++++++++-------------- cinderclient/tests/functional/base.py | 4 +-- cinderclient/tests/unit/v1/fakes.py | 3 +-- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/cinderclient/__init__.py b/cinderclient/__init__.py index aa7604567..dac207385 100644 --- a/cinderclient/__init__.py +++ b/cinderclient/__init__.py @@ -12,11 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. -__all__ = ['__version__'] - import pbr.version +__all__ = ['__version__'] + + version_info = pbr.version.VersionInfo('python-cinderclient') # We have a circular import problem when we first run python setup.py sdist # It's harmless, so deflect it. diff --git a/cinderclient/client.py b/cinderclient/client.py index b3abe2fcc..48940fad1 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -34,20 +34,18 @@ from keystoneauth1 import access from keystoneauth1 import adapter from keystoneauth1.identity import base from keystoneauth1 import discover +from oslo_utils import encodeutils +from oslo_utils import importutils +from oslo_utils import strutils +osprofiler_web = importutils.try_import("osprofiler.web") # noqa import requests +import six.moves.urllib.parse as urlparse from cinderclient import api_versions from cinderclient import exceptions import cinderclient.extension from cinderclient._i18n import _ from cinderclient._i18n import _LW -from oslo_utils import encodeutils -from oslo_utils import importutils -from oslo_utils import strutils - -osprofiler_web = importutils.try_import("osprofiler.web") - -import six.moves.urllib.parse as urlparse try: from eventlet import sleep diff --git a/cinderclient/shell.py b/cinderclient/shell.py index 3205783ea..150cc36b2 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -25,29 +25,28 @@ import getpass import logging import sys -import requests -import six - -from cinderclient import api_versions -from cinderclient import client -from cinderclient import exceptions as exc -from cinderclient import utils -import cinderclient.auth_plugin -from cinderclient._i18n import _ - from keystoneauth1 import discover from keystoneauth1 import loading from keystoneauth1 import session from keystoneauth1.identity import v2 as v2_auth from keystoneauth1.identity import v3 as v3_auth from keystoneauth1.exceptions import DiscoveryFailure -import six.moves.urllib.parse as urlparse from oslo_utils import encodeutils from oslo_utils import importutils +osprofiler_profiler = importutils.try_import("osprofiler.profiler") # noqa +import requests +import six +import six.moves.urllib.parse as urlparse -osprofiler_profiler = importutils.try_import("osprofiler.profiler") - +from cinderclient import api_versions +from cinderclient import client +from cinderclient import exceptions as exc from cinderclient import _i18n +from cinderclient._i18n import _ +from cinderclient import utils +import cinderclient.auth_plugin + + # Enable i18n lazy translation _i18n.enable_lazy() @@ -819,10 +818,9 @@ class OpenStackCinderShell(object): username = self.options.os_username password = self.options.os_password - tenant_id = (self.options.os_tenant_id - or self.options.os_project_id) - tenant_name = (self.options.os_tenant_name - or self.options.os_project_name) + tenant_id = self.options.os_tenant_id or self.options.os_project_id + tenant_name = (self.options.os_tenant_name or + self.options.os_project_name) return v2_auth.Password( v2_auth_url, @@ -839,8 +837,8 @@ class OpenStackCinderShell(object): user_domain_id = self.options.os_user_domain_id password = self.options.os_password project_id = self.options.os_project_id or self.options.os_tenant_id - project_name = (self.options.os_project_name - or self.options.os_tenant_name) + project_name = (self.options.os_project_name or + self.options.os_tenant_name) project_domain_name = self.options.os_project_domain_name project_domain_id = self.options.os_project_domain_id diff --git a/cinderclient/tests/functional/base.py b/cinderclient/tests/functional/base.py index 51cc492e8..cff88c03b 100644 --- a/cinderclient/tests/functional/base.py +++ b/cinderclient/tests/functional/base.py @@ -34,8 +34,8 @@ def credentials(): username = os.environ.get('OS_USERNAME') password = os.environ.get('OS_PASSWORD') - tenant_name = (os.environ.get('OS_TENANT_NAME') - or os.environ.get('OS_PROJECT_NAME')) + tenant_name = (os.environ.get('OS_TENANT_NAME') or + os.environ.get('OS_PROJECT_NAME')) auth_url = os.environ.get('OS_AUTH_URL') config = six.moves.configparser.RawConfigParser() diff --git a/cinderclient/tests/unit/v1/fakes.py b/cinderclient/tests/unit/v1/fakes.py index 13f16395d..59be02184 100644 --- a/cinderclient/tests/unit/v1/fakes.py +++ b/cinderclient/tests/unit/v1/fakes.py @@ -25,14 +25,13 @@ from cinderclient.v1 import client def _stub_volume(**kwargs): volume = { - 'id': '1234', + 'id': '00000000-0000-0000-0000-000000000000', 'display_name': None, 'display_description': None, "attachments": [], "bootable": "false", "availability_zone": "cinder", "created_at": "2012-08-27T00:00:00.000000", - "id": '00000000-0000-0000-0000-000000000000', "metadata": {}, "size": 1, "snapshot_id": None,