diff --git a/.pylintrc b/.pylintrc index e20c710f2d..f377306557 100644 --- a/.pylintrc +++ b/.pylintrc @@ -66,8 +66,6 @@ disable= too-many-locals, too-many-return-statements, too-many-statements, - # Better to be fixed but too many hits :( - unnecessary-comprehension, # TODO useless-object-inheritance [Basic] diff --git a/horizon/templatetags/angular.py b/horizon/templatetags/angular.py index 857806cc06..61b85629be 100644 --- a/horizon/templatetags/angular.py +++ b/horizon/templatetags/angular.py @@ -107,7 +107,7 @@ def angular_templates(context): # there will simply be no pre-loaded version for this template. pass - templates = [(key, value) for key, value in angular_templates.items()] + templates = list(angular_templates.items()) templates.sort(key=lambda item: item[0]) return { diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py index 2a4f790e6c..e8e9fed7b6 100644 --- a/openstack_auth/backend.py +++ b/openstack_auth/backend.py @@ -161,7 +161,7 @@ class KeystoneBackend(object): region_name = None id_endpoints = scoped_auth_ref.service_catalog.\ get_endpoints(service_type='identity') - for id_endpoint in [cat for cat in id_endpoints['identity']]: + for id_endpoint in id_endpoints['identity']: if auth_url in id_endpoint.values(): region_name = id_endpoint['region'] break diff --git a/openstack_dashboard/api/base.py b/openstack_dashboard/api/base.py index b7b00ce8e1..5a367b583f 100644 --- a/openstack_dashboard/api/base.py +++ b/openstack_dashboard/api/base.py @@ -314,7 +314,7 @@ def get_url_for_service(service, region, endpoint_type): # in the current region, it is okay to use the first endpoint for any # identity service endpoints and we can assume that it is global if service['type'] == 'identity' and not available_endpoints: - available_endpoints = [endpoint for endpoint in service_endpoints] + available_endpoints = service_endpoints for endpoint in available_endpoints: try: diff --git a/openstack_dashboard/api/rest/glance.py b/openstack_dashboard/api/rest/glance.py index 90368ddf0e..f27bda19ac 100644 --- a/openstack_dashboard/api/rest/glance.py +++ b/openstack_dashboard/api/rest/glance.py @@ -303,8 +303,7 @@ class MetadefsResourceTypesList(generic.View): Any request parameters will be passed through the API as filters. """ return { - 'items': [resource_type for resource_type in - api.glance.metadefs_resource_types_list(request)] + 'items': api.glance.metadefs_resource_types_list(request) } diff --git a/openstack_dashboard/api/rest/neutron.py b/openstack_dashboard/api/rest/neutron.py index 2bfe93c58b..4da558ef90 100644 --- a/openstack_dashboard/api/rest/neutron.py +++ b/openstack_dashboard/api/rest/neutron.py @@ -224,7 +224,8 @@ class Extensions(generic.View): http://localhost/api/neutron/extensions """ result = api.neutron.list_extensions(request) - return {'items': [e for e in result]} + # list_extensions can return a tuple, so list() is required. + return {'items': list(result)} class DefaultQuotaSets(generic.View): diff --git a/openstack_dashboard/api/rest/nova.py b/openstack_dashboard/api/rest/nova.py index 421f5e1d7c..2fe5bb48bd 100644 --- a/openstack_dashboard/api/rest/nova.py +++ b/openstack_dashboard/api/rest/nova.py @@ -309,7 +309,7 @@ class ConsoleOutput(generic.View): log_length = request.DATA.get('length', 100) console_lines = api.nova.server_console_output(request, server_id, tail_length=log_length) - return {"lines": [x for x in console_lines.split('\n')]} + return {"lines": console_lines.split('\n')} @urls.register diff --git a/openstack_dashboard/dashboards/admin/aggregates/tables.py b/openstack_dashboard/dashboards/admin/aggregates/tables.py index b3c1188c36..b67ff753ee 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/tables.py +++ b/openstack_dashboard/dashboards/admin/aggregates/tables.py @@ -114,7 +114,7 @@ class AvailabilityZoneFilterAction(tables.FilterAction): def get_aggregate_hosts(aggregate): - return [host for host in aggregate.hosts] + return aggregate.hosts def get_metadata(aggregate): diff --git a/openstack_dashboard/dashboards/admin/networks/ports/tables.py b/openstack_dashboard/dashboards/admin/networks/ports/tables.py index 10114aabf9..1ddd1aa840 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/tables.py @@ -41,7 +41,7 @@ class CreatePort(project_tables.CreatePort): request, tenant_id=tenant_id, targets=('port', )) if usages.get('port', {}).get('available', 1) <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ["disabled"] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _("Create Port (Quota exceeded)") else: self.verbose_name = _("Create Port") diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/tables.py b/openstack_dashboard/dashboards/admin/networks/subnets/tables.py index ffffc94209..dc8490b1df 100644 --- a/openstack_dashboard/dashboards/admin/networks/subnets/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/subnets/tables.py @@ -53,7 +53,7 @@ class CreateSubnet(proj_tables.SubnetPolicyTargetMixin, tables.LinkAction): # usages["subnet'] is empty if usages.get('subnet', {}).get('available', 1) <= 0: if 'disabled' not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _('Create Subnet (Quota exceeded)') else: self.verbose_name = _('Create Subnet') diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py index 3436a1d21d..4f7d77d042 100644 --- a/openstack_dashboard/dashboards/admin/networks/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/tables.py @@ -59,7 +59,7 @@ class CreateSubnet(project_tables.CreateSubnet): # usages["subnet'] is empty if usages.get('subnet', {}).get('available', 1) <= 0: if 'disabled' not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _('Create Subnet (Quota exceeded)') else: self.verbose_name = _('Create Subnet') diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py index 16ec1260f1..a0d6a3b89d 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py @@ -51,7 +51,7 @@ class AllocateIP(tables.LinkAction): targets=('floatingip', )) if 'floatingip' in usages and usages['floatingip']['available'] <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name, diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py index 252b71da11..f89eaef869 100644 --- a/openstack_dashboard/dashboards/project/instances/tables.py +++ b/openstack_dashboard/dashboards/project/instances/tables.py @@ -447,7 +447,7 @@ class LaunchLink(tables.LinkAction): if instances_available <= 0 or cores_available <= 0 \ or ram_available <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name, diff --git a/openstack_dashboard/dashboards/project/key_pairs/tables.py b/openstack_dashboard/dashboards/project/key_pairs/tables.py index 31feea6b58..77a145becc 100644 --- a/openstack_dashboard/dashboards/project/key_pairs/tables.py +++ b/openstack_dashboard/dashboards/project/key_pairs/tables.py @@ -57,7 +57,7 @@ class QuotaKeypairMixin(object): usages.tally('key_pairs', len(self.table.data)) if usages['key_pairs']['available'] <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name, diff --git a/openstack_dashboard/dashboards/project/networks/ports/tables.py b/openstack_dashboard/dashboards/project/networks/ports/tables.py index ac140b5fe4..7658a6beee 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/tables.py +++ b/openstack_dashboard/dashboards/project/networks/ports/tables.py @@ -91,7 +91,7 @@ class CreatePort(tables.LinkAction): # usages["port"] is empty if usages.get('port', {}).get('available', 1) <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ["disabled"] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _("Create Port (Quota exceeded)") else: # If the port is deleted, the usage of port will less than diff --git a/openstack_dashboard/dashboards/project/networks/subnets/tables.py b/openstack_dashboard/dashboards/project/networks/subnets/tables.py index 052062c96d..b44caf75c4 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/tables.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/tables.py @@ -111,7 +111,7 @@ class CreateSubnet(SubnetPolicyTargetMixin, tables.LinkAction): # usages["subnet'] is empty if usages.get('subnet', {}).get('available', 1) <= 0: if 'disabled' not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _('Create Subnet (Quota exceeded)') else: self.verbose_name = _('Create Subnet') diff --git a/openstack_dashboard/dashboards/project/networks/tables.py b/openstack_dashboard/dashboards/project/networks/tables.py index 3bbb95e656..ae07340ced 100644 --- a/openstack_dashboard/dashboards/project/networks/tables.py +++ b/openstack_dashboard/dashboards/project/networks/tables.py @@ -93,7 +93,7 @@ class CreateNetwork(tables.LinkAction): # usages["network"] is empty if usages.get('network', {}).get('available', 1) <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ["disabled"] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _("Create Network (Quota exceeded)") else: self.verbose_name = _("Create Network") @@ -135,7 +135,7 @@ class CreateSubnet(subnet_tables.SubnetPolicyTargetMixin, tables.LinkAction): # usages["subnet'] is empty if usages.get('subnet', {}).get('available', 1) <= 0: if 'disabled' not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _('Create Subnet (Quota exceeded)') else: self.verbose_name = _('Create Subnet') diff --git a/openstack_dashboard/dashboards/project/routers/tables.py b/openstack_dashboard/dashboards/project/routers/tables.py index 4a347ae329..0bc27856cb 100644 --- a/openstack_dashboard/dashboards/project/routers/tables.py +++ b/openstack_dashboard/dashboards/project/routers/tables.py @@ -89,7 +89,7 @@ class CreateRouter(tables.LinkAction): # usages['router'] is empty if usages.get('router', {}).get('available', 1) <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ["disabled"] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _("Create Router (Quota exceeded)") else: self.verbose_name = _("Create Router") diff --git a/openstack_dashboard/dashboards/project/security_groups/tables.py b/openstack_dashboard/dashboards/project/security_groups/tables.py index 6757b1cf18..92c0bd3fe8 100644 --- a/openstack_dashboard/dashboards/project/security_groups/tables.py +++ b/openstack_dashboard/dashboards/project/security_groups/tables.py @@ -70,7 +70,7 @@ class CreateGroup(tables.LinkAction): targets=('security_group', )) if usages['security_group'].get('available', 1) <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ["disabled"] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = _("Create Security Group (Quota exceeded)") else: self.verbose_name = _("Create Security Group") diff --git a/openstack_dashboard/dashboards/project/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/tables.py index f26a95ad08..7af8e1703e 100644 --- a/openstack_dashboard/dashboards/project/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/tables.py @@ -152,7 +152,7 @@ class CreateVolume(tables.LinkAction): if gb_available <= 0 or volumes_available <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name, @@ -227,7 +227,7 @@ class CreateSnapshot(VolumePolicyTargetMixin, tables.LinkAction): limits.get('totalSnapshotsUsed', 0)) if snapshots_available <= 0 and "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name, @@ -315,7 +315,7 @@ class AcceptTransfer(tables.LinkAction): volumes_available = usages['volumes']['available'] if gb_available <= 0 or volumes_available <= 0: if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] + self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name,