diff --git a/.pylintrc b/.pylintrc index fbf048414d2..a9d30f45c04 100644 --- a/.pylintrc +++ b/.pylintrc @@ -147,7 +147,6 @@ disable= unidiomatic-typecheck, consider-using-enumerate, bad-whitespace, - consider-iterating-dictionary, line-too-long, useless-super-delegation, pointless-string-statement, diff --git a/cinder/quota.py b/cinder/quota.py index 00982643a5b..77155109a6d 100644 --- a/cinder/quota.py +++ b/cinder/quota.py @@ -484,7 +484,7 @@ class NestedDbQuotaDriver(DbQuotaDriver): ctxt, resources, cur_proj_id) # Validate each resource when compared to it's child quotas - for resource in cur_project_quotas.keys(): + for resource in cur_project_quotas: parent_quota = cur_project_quotas[resource] parent_limit = parent_quota['limit'] parent_usage = (parent_quota['in_use'] + @@ -619,7 +619,7 @@ class NestedDbQuotaDriver(DbQuotaDriver): context, resources, project_id) # All defaults are 0 for child project if quota_utils.get_parent_project_id(context, project_id): - for key in defaults.keys(): + for key in defaults: defaults[key] = 0 return defaults diff --git a/cinder/scheduler/host_manager.py b/cinder/scheduler/host_manager.py index 144a1f294a3..725707623bd 100644 --- a/cinder/scheduler/host_manager.py +++ b/cinder/scheduler/host_manager.py @@ -840,7 +840,7 @@ class HostManager(object): for old_pool in old_pools: oldpools[old_pool['pool_name']] = old_pool - for key in newpools.keys(): + for key in newpools: if key in oldpools.keys(): for k in self.REQUIRED_KEYS: if newpools[key][k] != oldpools[key][k]: diff --git a/cinder/test.py b/cinder/test.py index be61f4aa04c..007bbb1b04e 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -347,7 +347,7 @@ class TestCase(testtools.TestCase): # Delete attributes that don't start with _ so they don't pin # memory around unnecessarily for the duration of the test # suite - for key in [k for k in self.__dict__.keys() if k[0] != '_']: + for key in [k for k in self.__dict__ if k[0] != '_']: del self.__dict__[key] def override_config(self, name, override, group=None): diff --git a/cinder/utils.py b/cinder/utils.py index cd537bc9a63..829b1f05516 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -113,7 +113,7 @@ def check_exclusive_options(**kwargs): # # Ex: 'the_key' -> 'the key' if pretty_keys: - names = [k.replace('_', ' ') for k in kwargs.keys()] + names = [k.replace('_', ' ') for k in kwargs] else: names = kwargs.keys() names = ", ".join(sorted(names)) diff --git a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py index d639db6c952..a453b296099 100644 --- a/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py +++ b/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py @@ -1723,7 +1723,7 @@ class SCApi(object): # Return the response in lowercase wwns_lower = [w.lower() for w in wwns] itmap_lower = dict() - for key in itmap.keys(): + for key in itmap: itmap_lower[key.lower()] = [v.lower() for v in itmap[key]] return lun, wwns_lower, itmap_lower diff --git a/cinder/volume/drivers/huawei/huawei_driver.py b/cinder/volume/drivers/huawei/huawei_driver.py index de6b6b1da51..7e880cb492f 100644 --- a/cinder/volume/drivers/huawei/huawei_driver.py +++ b/cinder/volume/drivers/huawei/huawei_driver.py @@ -684,7 +684,7 @@ class HuaweiBaseDriver(driver.VolumeDriver): self.configuration.lun_write_cache_policy), 'OWNINGCONTROLLER': lun_info['OWNINGCONTROLLER'], } - for item in lun_params.keys(): + for item in lun_params: if lun_params.get(item) == '--': del lun_params[item] diff --git a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py index 0aeedb774ba..f72d3177ad5 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py +++ b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py @@ -1602,7 +1602,7 @@ class XIVProxy(proxy.IBMStorageProxy): self.meta['stat']['rpo'] = repl.Replication.get_supported_rpo() self.meta['stat']['replication_count'] = len(self.targets) self.meta['stat']['replication_targets'] = [target for target in - self.targets.keys()] + self.targets] self.meta['stat']['timestamp'] = datetime.datetime.utcnow() diff --git a/cinder/volume/drivers/netapp/dataontap/client/api.py b/cinder/volume/drivers/netapp/dataontap/client/api.py index 7f1c96c0065..4e530dd2e04 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/api.py +++ b/cinder/volume/drivers/netapp/dataontap/client/api.py @@ -340,7 +340,7 @@ class NaElement(object): def add_attrs(self, **attrs): """Add multiple attributes to the element.""" - for attr in attrs.keys(): + for attr in attrs: self._element.set(attr, attrs.get(attr)) def add_child_elem(self, na_element): @@ -405,7 +405,7 @@ class NaElement(object): def create_node_with_children(node, **children): """Creates and returns named node with children.""" parent = NaElement(node) - for child in children.keys(): + for child in children: parent.add_new_child(child, children.get(child, None)) return parent diff --git a/cinder/volume/drivers/nexenta/ns5/iscsi.py b/cinder/volume/drivers/nexenta/ns5/iscsi.py index 84ebf05a7a0..d205614acec 100644 --- a/cinder/volume/drivers/nexenta/ns5/iscsi.py +++ b/cinder/volume/drivers/nexenta/ns5/iscsi.py @@ -322,7 +322,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): else: # Choose the best target group among existing ones tg_name = None - for tg in self.volumes.keys(): + for tg in self.volumes: if len(self.volumes[tg]) < 20: tg_name = tg break diff --git a/cinder/volume/drivers/prophetstor/dpl_fc.py b/cinder/volume/drivers/prophetstor/dpl_fc.py index 2e6c74ba286..14824117a7e 100644 --- a/cinder/volume/drivers/prophetstor/dpl_fc.py +++ b/cinder/volume/drivers/prophetstor/dpl_fc.py @@ -250,8 +250,8 @@ class DPLFCDriver(dplcommon.DPLCOMMONDriver, 'target.') raise exception.VolumeBackendAPIException(data=msg) - for keyFc in dc_fc.keys(): - for targetuuid in dc_target.keys(): + for keyFc in dc_fc: + for targetuuid in dc_target: if dc_fc[keyFc]['hardware_address'] == \ dc_target[targetuuid]['targetAddr']: preferTargets[targetuuid] = dc_target[targetuuid] @@ -267,7 +267,7 @@ class DPLFCDriver(dplcommon.DPLCOMMONDriver, szwwpns.append(szwwpn) if len(szwwpns): - for targetUuid in preferTargets.keys(): + for targetUuid in preferTargets: targetWwpn = '' targetWwpn = preferTargets.get(targetUuid, {}).get('targetAddr', '') diff --git a/cinder/volume/drivers/quobyte.py b/cinder/volume/drivers/quobyte.py index 0cc8d00b498..3a6f3175adf 100644 --- a/cinder/volume/drivers/quobyte.py +++ b/cinder/volume/drivers/quobyte.py @@ -592,7 +592,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed): self._load_shares_config() - for share in self.shares.keys(): + for share in self.shares: try: self._ensure_share_mounted(share) self._mounted_shares.append(share) diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py index cc1d507c033..ad9da0c76cf 100644 --- a/cinder/volume/drivers/remotefs.py +++ b/cinder/volume/drivers/remotefs.py @@ -317,7 +317,7 @@ class RemoteFSDriver(driver.BaseVD): self.driver_prefix + '_shares_config')) - for share in self.shares.keys(): + for share in self.shares: try: self._ensure_share_mounted(share) mounted_shares.append(share) diff --git a/cinder/volume/drivers/tintri.py b/cinder/volume/drivers/tintri.py index 23e68d0681f..61c40b05aaf 100644 --- a/cinder/volume/drivers/tintri.py +++ b/cinder/volume/drivers/tintri.py @@ -803,7 +803,7 @@ class TintriDriver(driver.ManageableVD, mounted_image_shares = [] if self._image_shares_config: self._load_shares_config(self._image_shares_config) - for share in self.shares.keys(): + for share in self.shares: try: self._ensure_share_mounted(share) mounted_image_shares.append(share)