Get rid of keys() usage

for x in some_dict.keys() can be written as for x in some_dict

Change-Id: If5436647a30c02d0dab7daa23b2290456c66d654
This commit is contained in:
manchandavishal 2018-11-30 11:15:27 +00:00
parent 7899b04888
commit c02b9fc2dd
7 changed files with 7 additions and 7 deletions

View File

@ -209,7 +209,7 @@ class Registry(object):
raise ValueError('Only %s classes or subclasses may be '
'unregistered.' % self._registerable_class)
if cls not in self._registry.keys():
if cls not in self._registry:
raise NotRegistered('%s is not registered' % cls)
del self._registry[cls]

View File

@ -55,7 +55,7 @@ def _get_enforcer():
_ENFORCER = {}
policy_files = getattr(settings, 'POLICY_FILES', {})
policy_dirs = getattr(settings, 'POLICY_DIRS', {})
for service in policy_files.keys():
for service in policy_files:
conf = _get_policy_conf(policy_file=policy_files[service],
policy_dirs=policy_dirs.get(service, []))
enforcer = policy.Enforcer(conf)

View File

@ -327,7 +327,7 @@ class UpdateDomain(workflows.Workflow):
domain=domain_id)
users_dict = {user.id: user.name for user in all_users}
for user_id in users_roles.keys():
for user_id in users_roles:
# Don't remove roles if the user isn't in the domain
if user_id not in users_dict:
users_to_modify -= 1

View File

@ -794,7 +794,7 @@ class UpdateProject(workflows.Workflow):
domain=data['domain_id'])
users_dict = {user.id: user.name for user in all_users}
for user_id in users_roles.keys():
for user_id in users_roles:
# Don't remove roles if the user isn't in the domain
if user_id not in users_dict:
users_to_modify -= 1

View File

@ -417,7 +417,7 @@ class CinderApiTests(test.APIMockTestCase):
ret_val = api.cinder.tenant_absolute_limits(self.request)
for key in expected_results.keys():
for key in expected_results:
self.assertEqual(expected_results[key], ret_val[key])
mock_limit.assert_called_once()

View File

@ -359,7 +359,7 @@ class ComputeApiTests(test.APIMockTestCase):
ret_val = api.nova.tenant_absolute_limits(self.request, reserved=True)
for key in expected_results.keys():
for key in expected_results:
self.assertEqual(expected_results[key], ret_val[key])
novaclient.limits.get.assert_called_once_with(reserved=True,
tenant_id=None)

View File

@ -127,7 +127,7 @@ class Literal(types.ConfigType):
for value in result.values():
self.validate(value, spec_value)
spec_key = next(iter(spec.keys()))
for key in result.keys():
for key in result:
self.validate(key, spec_key)
if isinstance(spec, list):
if not isinstance(result, list):