summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-01-16 14:25:39 +0000
committerGerrit Code Review <review@openstack.org>2019-01-16 14:25:39 +0000
commitc9536342c22000ad9f8d81d52424b3d3412c29fb (patch)
treee95058261f2b33aebca9c243932f8029c28fab51
parent32f5338a4fc4c1a8a220bb9ccb232f69e2e59f7e (diff)
parentc076db20c8650df35799d2582c40a85788f37be8 (diff)
downloadhorizon-c9536342c22000ad9f8d81d52424b3d3412c29fb.tar.gz
Merge "pylint: fix len-as-condition warning"
-rw-r--r--.pylintrc1
-rw-r--r--horizon/base.py6
-rw-r--r--horizon/middleware/operation_log.py2
-rw-r--r--horizon/tables/base.py2
-rw-r--r--horizon/utils/babel_extract_angular.py2
-rw-r--r--horizon/workflows/base.py2
-rw-r--r--openstack_dashboard/api/base.py2
-rw-r--r--openstack_dashboard/api/keystone.py2
-rw-r--r--openstack_dashboard/api/nova.py4
-rw-r--r--openstack_dashboard/api/rest/keystone.py4
-rw-r--r--openstack_dashboard/contrib/developer/profiler/api.py2
-rw-r--r--openstack_dashboard/dashboards/admin/info/tables.py3
-rw-r--r--openstack_dashboard/dashboards/admin/networks/forms.py2
-rw-r--r--openstack_dashboard/dashboards/identity/domains/workflows.py2
-rw-r--r--openstack_dashboard/dashboards/identity/groups/views.py3
-rw-r--r--openstack_dashboard/dashboards/identity/projects/views.py3
-rw-r--r--openstack_dashboard/dashboards/identity/projects/workflows.py2
-rw-r--r--openstack_dashboard/dashboards/identity/roles/views.py2
-rw-r--r--openstack_dashboard/dashboards/identity/users/views.py2
-rw-r--r--openstack_dashboard/dashboards/project/cgroups/forms.py4
-rw-r--r--openstack_dashboard/dashboards/project/instances/forms.py2
-rw-r--r--openstack_dashboard/dashboards/project/networks/workflows.py10
-rw-r--r--openstack_dashboard/dashboards/project/volume_groups/forms.py4
23 files changed, 32 insertions, 36 deletions
diff --git a/.pylintrc b/.pylintrc
index 5f1b7218a..4467968d5 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -45,7 +45,6 @@ disable=
expression-not-assigned,
global-statement,
invalid-name,
- len-as-condition,
line-too-long,
misplaced-comparison-constant,
missing-docstring,
diff --git a/horizon/base.py b/horizon/base.py
index 1cf641a30..28ffe4824 100644
--- a/horizon/base.py
+++ b/horizon/base.py
@@ -519,7 +519,7 @@ class Dashboard(Registry, HorizonComponent):
panel_groups.append((panel_group.slug, panel_group))
# Deal with leftovers (such as add-on registrations)
- if len(registered):
+ if registered:
slugs = [panel.slug for panel in registered.values()]
new_group = PanelGroup(self,
slug="other",
@@ -769,7 +769,7 @@ class Site(Registry, HorizonComponent):
dashboard = self._registered(item)
dashboards.append(dashboard)
registered.pop(dashboard.__class__)
- if len(registered):
+ if registered:
extra = sorted(registered.values())
dashboards.extend(extra)
return dashboards
@@ -785,7 +785,7 @@ class Site(Registry, HorizonComponent):
"""
if self.default_dashboard:
return self._registered(self.default_dashboard)
- elif len(self._registry):
+ elif self._registry:
return self.get_dashboards()[0]
else:
raise NotRegistered("No dashboard modules have been registered.")
diff --git a/horizon/middleware/operation_log.py b/horizon/middleware/operation_log.py
index 87294f480..30dde2087 100644
--- a/horizon/middleware/operation_log.py
+++ b/horizon/middleware/operation_log.py
@@ -182,7 +182,7 @@ class OperationLogMiddleware(object):
# when a file uploaded (E.g create image)
files = request.FILES.values()
- if len(list(files)) > 0:
+ if list(files):
filenames = ', '.join(
[up_file.name for up_file in files])
params['file_name'] = filenames
diff --git a/horizon/tables/base.py b/horizon/tables/base.py
index 82b74138c..a9bce95da 100644
--- a/horizon/tables/base.py
+++ b/horizon/tables/base.py
@@ -496,7 +496,7 @@ class Column(html.HTMLElement):
data = [self.get_raw_data(datum) for datum in self.table.data]
data = [raw_data for raw_data in data if raw_data is not None]
- if len(data):
+ if data:
try:
summation = summation_function(data)
for filter_func in self.filters:
diff --git a/horizon/utils/babel_extract_angular.py b/horizon/utils/babel_extract_angular.py
index cdf4bd581..eb231ac67 100644
--- a/horizon/utils/babel_extract_angular.py
+++ b/horizon/utils/babel_extract_angular.py
@@ -123,7 +123,7 @@ class AngularGettextHTMLParser(html_parser.HTMLParser):
def handle_endtag(self, tag):
if self.in_translate:
- if len(self.inner_tags) > 0:
+ if self.inner_tags:
tag = self.inner_tags.pop()
self.data += "</%s>" % tag
return
diff --git a/horizon/workflows/base.py b/horizon/workflows/base.py
index 3334d29f9..7a6ccace3 100644
--- a/horizon/workflows/base.py
+++ b/horizon/workflows/base.py
@@ -904,7 +904,7 @@ class Workflow(html.HTMLElement):
def verify_integrity(self):
provided_keys = self.contributions | set(self.context_seed.keys())
- if len(self.depends_on - provided_keys):
+ if self.depends_on - provided_keys:
raise exceptions.NotAvailable(
_("The current user has insufficient permission to complete "
"the requested task."))
diff --git a/openstack_dashboard/api/base.py b/openstack_dashboard/api/base.py
index 68916c88f..89d900b32 100644
--- a/openstack_dashboard/api/base.py
+++ b/openstack_dashboard/api/base.py
@@ -258,7 +258,7 @@ class QuotaSet(Sequence):
def get(self, key, default=None):
match = [quota for quota in self.items if quota.name == key]
- return match.pop() if len(match) else Quota(key, default)
+ return match.pop() if match else Quota(key, default)
def add(self, other):
return self.__add__(other)
diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py
index 058e1a5f4..0ca69cfcf 100644
--- a/openstack_dashboard/api/keystone.py
+++ b/openstack_dashboard/api/keystone.py
@@ -634,7 +634,7 @@ def group_list(request, domain=None, project=None, user=None, filters=None):
project_groups = []
for group in groups:
roles = roles_for_group(request, group=group.id, project=project)
- if roles and len(roles) > 0:
+ if roles:
project_groups.append(group)
groups = project_groups
return groups
diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py
index 71832345f..bbea79833 100644
--- a/openstack_dashboard/api/nova.py
+++ b/openstack_dashboard/api/nova.py
@@ -602,14 +602,14 @@ def server_list_paged(request,
servers = [Server(s, request)
for s in nova_client.servers.list(detailed, search_opts)]
if view_marker == 'possibly_deleted':
- if len(servers) == 0:
+ if not servers:
view_marker = 'head_deleted'
search_opts['sort_dir'] = 'desc'
reversed_order = False
servers = [Server(s, request)
for s in nova_client.servers.list(detailed,
search_opts)]
- if len(servers) == 0:
+ if not servers:
view_marker = 'tail_deleted'
search_opts['sort_dir'] = 'asc'
reversed_order = True
diff --git a/openstack_dashboard/api/rest/keystone.py b/openstack_dashboard/api/rest/keystone.py
index 3060590a3..4e734aef4 100644
--- a/openstack_dashboard/api/rest/keystone.py
+++ b/openstack_dashboard/api/rest/keystone.py
@@ -56,7 +56,7 @@ class Users(generic.View):
filters = rest_utils.parse_filters_kwargs(request,
self.client_keywords)[0]
- if len(filters) == 0:
+ if not filters:
filters = None
result = api.keystone.user_list(
@@ -420,7 +420,7 @@ class Projects(generic.View):
filters = rest_utils.parse_filters_kwargs(request,
self.client_keywords)[0]
- if len(filters) == 0:
+ if not filters:
filters = None
paginate = request.GET.get('paginate') == 'true'
diff --git a/openstack_dashboard/contrib/developer/profiler/api.py b/openstack_dashboard/contrib/developer/profiler/api.py
index 240ca294a..3d1bcdb9e 100644
--- a/openstack_dashboard/contrib/developer/profiler/api.py
+++ b/openstack_dashboard/contrib/developer/profiler/api.py
@@ -89,7 +89,7 @@ def list_traces(request):
def get_trace(request, trace_id):
def rec(_data, level=0):
_data['level'] = level
- _data['is_leaf'] = not len(_data['children'])
+ _data['is_leaf'] = not _data['children']
_data['visible'] = True
_data['childrenVisible'] = True
finished = _data['info']['finished']
diff --git a/openstack_dashboard/dashboards/admin/info/tables.py b/openstack_dashboard/dashboards/admin/info/tables.py
index 9e5b3ef4e..99a7ece18 100644
--- a/openstack_dashboard/dashboards/admin/info/tables.py
+++ b/openstack_dashboard/dashboards/admin/info/tables.py
@@ -59,8 +59,7 @@ def show_endpoints(datanum):
if 'endpoints' in datanum:
template_name = 'admin/info/_cell_endpoints_v2.html'
context = None
- if (len(datanum['endpoints']) > 0 and
- "publicURL" in datanum['endpoints'][0]):
+ if (datanum['endpoints'] and "publicURL" in datanum['endpoints'][0]):
context = datanum['endpoints'][0]
else:
# this is a keystone v3 version of endpoints
diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py
index 0c4dd5fc3..3796fdca1 100644
--- a/openstack_dashboard/dashboards/admin/networks/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/forms.py
@@ -238,7 +238,7 @@ class CreateNetwork(forms.SelfHandlingForm):
network_type_choices = [
(net_type, self.provider_types[net_type]['display_name'])
for net_type in supported_provider_types]
- if len(network_type_choices) == 0:
+ if not network_type_choices:
self._hide_provider_network_type()
else:
self.fields['network_type'].choices = network_type_choices
diff --git a/openstack_dashboard/dashboards/identity/domains/workflows.py b/openstack_dashboard/dashboards/identity/domains/workflows.py
index 81bf94b85..8c518573c 100644
--- a/openstack_dashboard/dashboards/identity/domains/workflows.py
+++ b/openstack_dashboard/dashboards/identity/domains/workflows.py
@@ -368,7 +368,7 @@ class UpdateDomain(workflows.Workflow):
]
admin_role_ids = [role for role in current_role_ids
if role in available_admin_role_ids]
- if len(admin_role_ids):
+ if admin_role_ids:
removing_admin = any([role in current_role_ids
for role in admin_role_ids])
else:
diff --git a/openstack_dashboard/dashboards/identity/groups/views.py b/openstack_dashboard/dashboards/identity/groups/views.py
index ef3df9d29..ba461f8e0 100644
--- a/openstack_dashboard/dashboards/identity/groups/views.py
+++ b/openstack_dashboard/dashboards/identity/groups/views.py
@@ -54,8 +54,7 @@ class IndexView(tables.DataTableView):
# selected, then search criteria must be provided and
# return an empty list
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
- if filter_first.get('identity.groups', False) \
- and len(filters) == 0:
+ if filter_first.get('identity.groups', False) and not filters:
self._needs_filter_first = True
return groups
diff --git a/openstack_dashboard/dashboards/identity/projects/views.py b/openstack_dashboard/dashboards/identity/projects/views.py
index 74618cc12..6d3e842e6 100644
--- a/openstack_dashboard/dashboards/identity/projects/views.py
+++ b/openstack_dashboard/dashboards/identity/projects/views.py
@@ -96,8 +96,7 @@ class IndexView(tables.DataTableView):
# selected, then search criteria must be provided and
# return an empty list
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
- if filter_first.get('identity.projects', False) and len(
- filters) == 0:
+ if filter_first.get('identity.projects', False) and not filters:
self._needs_filter_first = True
self._more = False
return tenants
diff --git a/openstack_dashboard/dashboards/identity/projects/workflows.py b/openstack_dashboard/dashboards/identity/projects/workflows.py
index 0b6e648c5..837d4f451 100644
--- a/openstack_dashboard/dashboards/identity/projects/workflows.py
+++ b/openstack_dashboard/dashboards/identity/projects/workflows.py
@@ -752,7 +752,7 @@ class UpdateProject(workflows.Workflow):
if role.name.lower() in _admin_roles]
admin_roles = [role for role in current_role_ids
if role in available_admin_role_ids]
- if len(admin_roles):
+ if admin_roles:
removing_admin = any([role in current_role_ids
for role in admin_roles])
else:
diff --git a/openstack_dashboard/dashboards/identity/roles/views.py b/openstack_dashboard/dashboards/identity/roles/views.py
index eb74b8361..c829dcfb5 100644
--- a/openstack_dashboard/dashboards/identity/roles/views.py
+++ b/openstack_dashboard/dashboards/identity/roles/views.py
@@ -52,7 +52,7 @@ class IndexView(tables.DataTableView):
# selected, then search criteria must be provided
# and return an empty list
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
- if filter_first.get('identity.roles', False) and len(filters) == 0:
+ if filter_first.get('identity.roles', False) and not filters:
self._needs_filter_first = True
return roles
diff --git a/openstack_dashboard/dashboards/identity/users/views.py b/openstack_dashboard/dashboards/identity/users/views.py
index 0aa319f90..2fe737eaa 100644
--- a/openstack_dashboard/dashboards/identity/users/views.py
+++ b/openstack_dashboard/dashboards/identity/users/views.py
@@ -68,7 +68,7 @@ class IndexView(tables.DataTableView):
# selected, then search criteria must be provided
# and return an empty list
filter_first = getattr(settings, 'FILTER_DATA_FIRST', {})
- if filter_first.get('identity.users', False) and len(filters) == 0:
+ if filter_first.get('identity.users', False) and not filters:
self._needs_filter_first = True
return users
diff --git a/openstack_dashboard/dashboards/project/cgroups/forms.py b/openstack_dashboard/dashboards/project/cgroups/forms.py
index 2dbd94000..6712da517 100644
--- a/openstack_dashboard/dashboards/project/cgroups/forms.py
+++ b/openstack_dashboard/dashboards/project/cgroups/forms.py
@@ -149,7 +149,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
else:
search_opts = {'consistentcygroup_id': data['cgroup_id']}
volumes = cinder.volume_list(request, search_opts=search_opts)
- if len(volumes) == 0:
+ if not volumes:
msg = _('Unable to create snapshot. Consistency group '
'must contain volumes.')
@@ -208,7 +208,7 @@ class CloneCGroupForm(forms.SelfHandlingForm):
search_opts = {'consistentcygroup_id': data['cgroup_id']}
volumes = cinder.volume_list(request, search_opts=search_opts)
- if len(volumes) == 0:
+ if not volumes:
msg = _('Unable to clone empty consistency group.')
exceptions.handle(request,
diff --git a/openstack_dashboard/dashboards/project/instances/forms.py b/openstack_dashboard/dashboards/project/instances/forms.py
index f3d510a30..ea5cc5f44 100644
--- a/openstack_dashboard/dashboards/project/instances/forms.py
+++ b/openstack_dashboard/dashboards/project/instances/forms.py
@@ -347,7 +347,7 @@ class AttachInterface(forms.SelfHandlingForm):
choices = [('network', _("by Network (and IP address)"))]
ports = instance_utils.port_field_data(request, with_network=True)
- if len(ports) > 0:
+ if ports:
self.fields['port'].choices = ports
choices.append(('port', _("by Port")))
diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py
index 391d4ce3f..8a9683c47 100644
--- a/openstack_dashboard/dashboards/project/networks/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/workflows.py
@@ -235,10 +235,10 @@ class CreateSubnetInfoAction(workflows.Action):
# Populate data-fields for switching the prefixlen field
# when user selects a subnetpool other than
# "Provider default pool"
- for (id, name) in self.fields['subnetpool'].choices:
- if not len(id):
+ for (id_, name) in self.fields['subnetpool'].choices:
+ if not id_:
continue
- key = 'data-subnetpool-' + id
+ key = 'data-subnetpool-' + id_
self.fields['prefixlen'].widget.attrs[key] = \
_('Network Mask')
else:
@@ -555,9 +555,9 @@ class CreateNetwork(workflows.Workflow):
params['gateway_ip'] = None
elif data['gateway_ip']:
params['gateway_ip'] = data['gateway_ip']
- if 'subnetpool' in data and len(data['subnetpool']):
+ if 'subnetpool' in data and data['subnetpool']:
params['subnetpool_id'] = data['subnetpool']
- if 'prefixlen' in data and len(data['prefixlen']):
+ if 'prefixlen' in data and data['prefixlen']:
params['prefixlen'] = data['prefixlen']
self._setup_subnet_parameters(params, data)
diff --git a/openstack_dashboard/dashboards/project/volume_groups/forms.py b/openstack_dashboard/dashboards/project/volume_groups/forms.py
index 312bbeb03..d19a99331 100644
--- a/openstack_dashboard/dashboards/project/volume_groups/forms.py
+++ b/openstack_dashboard/dashboards/project/volume_groups/forms.py
@@ -136,7 +136,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
search_opts = {'group_id': group_id}
volumes = cinder.volume_list(request,
search_opts=search_opts)
- if len(volumes) == 0:
+ if not volumes:
msg = _('Unable to create snapshot. '
'group must contain volumes.')
@@ -190,7 +190,7 @@ class CloneGroupForm(forms.SelfHandlingForm):
search_opts = {'group_id': group_id}
volumes = cinder.volume_list(request, search_opts=search_opts)
- if len(volumes) == 0:
+ if not volumes:
msg = _('Unable to clone empty group.')
exceptions.handle(request,