pylint: fix several coding convention violations

openstack_dashboard/context_processors.py:94:15: C0122: Comparison should be link['url'] != 'horizon:project:api_access:openrcv2' (misplaced-comparison-constant)
openstack_dashboard/settings.py:467:4: C0412: Imports from package horizon are not grouped (ungrouped-imports)
openstack_dashboard/enabled/_1370_project_vg_snapshots.py:9:0: C0301: Line too long (86/80) (line-too-long)
openstack_dashboard/enabled/_1360_project_volume_groups.py:9:0: C0301: Line too long (85/80) (line-too-long)
openstack_dashboard/usage/base.py:62:8: W0106: Expression "[instance_list.extend(u.server_usages) for u in self.usage_list]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:43:12: W0106: Expression "[public_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:75:12: W0106: Expression "[community_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/api/glance.py:47:4: C0412: Imports from package glanceclient are not grouped (ungrouped-imports)
openstack_dashboard/api/cinder.py:60:4: C0412: Imports from package cinderclient are not grouped (ungrouped-imports)
openstack_auth/user.py:358:4: E0211: Method has no argument (no-method-argument)
openstack_auth/user.py:362:4: E0211: Method has no argument (no-method-argument)
openstack_dashboard/api/keystone.py:75:4: C0412: Imports from package keystoneclient are not grouped (ungrouped-imports)
horizon/loaders.py:43:16: W0706: The except handler raises immediately (try-except-raise)
horizon/themes.py:174:8: W0706: The except handler raises immediately (try-except-raise)

Change-Id: I40cf3ffbc4519657e11180d2e2fe7401387c5556
This commit is contained in:
Akihiro Motoki 2018-12-02 06:21:02 +09:00
parent c9536342c2
commit ac7ac272b3
13 changed files with 19 additions and 16 deletions

View File

@ -42,17 +42,11 @@ disable=
bad-builtin,
bad-continuation,
deprecated-lambda,
expression-not-assigned,
global-statement,
invalid-name,
line-too-long,
misplaced-comparison-constant,
missing-docstring,
no-method-argument,
superfluous-parens,
too-many-lines,
try-except-raise,
ungrouped-imports,
unused-variable,
wrong-import-order, # TODO
# "R" Refactor recommendations

View File

@ -40,6 +40,7 @@ class TemplateLoader(filesystem_loader.Loader):
yield Origin(name=name,
template_name=template_name,
loader=self)
# pylint: disable=try-except-raise
except UnicodeDecodeError:
# The template dir name wasn't valid UTF-8.
raise

View File

@ -170,7 +170,7 @@ class ThemeTemplateLoader(filesystem_loader.Loader):
yield Origin(name=name,
template_name=template_name,
loader=self)
# pylint: disable=try-except-raise
except UnicodeDecodeError:
# The template dir name wasn't valid UTF-8.
raise

View File

@ -331,11 +331,11 @@ class User(models.AbstractBaseUser, models.AnonymousUser):
regions.append(region)
return regions
def save(*args, **kwargs):
def save(self, *args, **kwargs):
# Presume we can't write to Keystone.
pass
def delete(*args, **kwargs):
def delete(self, *args, **kwargs):
# Presume we can't write to Keystone.
pass

View File

@ -57,6 +57,7 @@ CONSUMER_CHOICES = (
VERSIONS = base.APIVersionManager("volume", preferred_version='3')
try:
# pylint: disable=ungrouped-imports
from cinderclient.v2 import client as cinder_client_v2
VERSIONS.load_supported_version('2', {"client": cinder_client_v2,
"version": '2'})

View File

@ -44,13 +44,14 @@ LOG = logging.getLogger(__name__)
VERSIONS = base.APIVersionManager("image", preferred_version=2)
try:
# pylint: disable=ungrouped-imports
from glanceclient.v2 import client as glance_client_v2
VERSIONS.load_supported_version(2, {"client": glance_client_v2,
"version": 2})
except ImportError:
pass
try:
# pylint: disable=ungrouped-imports
from glanceclient.v1 import client as glance_client_v1
VERSIONS.load_supported_version(1, {"client": glance_client_v1,
"version": 1})

View File

@ -72,12 +72,14 @@ VERSIONS = IdentityAPIVersionManager(
# Import from oldest to newest so that "preferred" takes correct precedence.
try:
# pylint: disable=ungrouped-imports
from keystoneclient.v2_0 import client as keystone_client_v2
VERSIONS.load_supported_version(2.0, {"client": keystone_client_v2})
except ImportError:
pass
try:
# pylint: disable=ungrouped-imports
from keystoneclient.v3 import client as keystone_client_v3
VERSIONS.load_supported_version(3, {"client": keystone_client_v3})
except ImportError:

View File

@ -91,7 +91,7 @@ def openstack(request):
if not getattr(settings, "SHOW_KEYSTONE_V2_RC", False):
user_menu_links = [
link for link in user_menu_links
if 'horizon:project:api_access:openrcv2' != link['url']]
if link['url'] != 'horizon:project:api_access:openrcv2']
context['USER_MENU_LINKS'] = user_menu_links

View File

@ -41,7 +41,7 @@ def get_available_images(request, project_id=None, images_cache=None):
try:
images, _more, _prev = glance.image_list_detailed(
request, filters=public)
[public_images.append(image) for image in images]
public_images += images
images_cache['public_images'] = public_images
except Exception:
exceptions.handle(request,
@ -72,7 +72,7 @@ def get_available_images(request, project_id=None, images_cache=None):
try:
images, _more, _prev = glance.image_list_detailed(
request, filters=community)
[community_images.append(image) for image in images]
community_images += images
images_cache['community_images'] = community_images
except Exception:
exceptions.handle(request,

View File

@ -6,4 +6,5 @@ PANEL_DASHBOARD = 'project'
PANEL_GROUP = 'volumes'
# Python panel class of the PANEL to be added.
ADD_PANEL = 'openstack_dashboard.dashboards.project.volume_groups.panel.VolumeGroups'
ADD_PANEL = ('openstack_dashboard.dashboards.project.volume_groups.panel.'
'VolumeGroups')

View File

@ -6,4 +6,5 @@ PANEL_DASHBOARD = 'project'
PANEL_GROUP = 'volumes'
# Python panel class of the PANEL to be added.
ADD_PANEL = 'openstack_dashboard.dashboards.project.vg_snapshots.panel.GroupSnapshots'
ADD_PANEL = ('openstack_dashboard.dashboards.project.vg_snapshots.panel.'
'GroupSnapshots')

View File

@ -478,6 +478,7 @@ if not SECRET_KEY:
LOCAL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'local')
# pylint: disable=ungrouped-imports
from horizon.utils import secret_key
SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH,
'.secret_key_store'))

View File

@ -59,7 +59,8 @@ class BaseUsage(object):
def get_instances(self):
instance_list = []
[instance_list.extend(u.server_usages) for u in self.usage_list]
for u in self.usage_list:
instance_list.extend(u.server_usages)
return instance_list
def get_date_range(self):