From c02b9fc2dd7aaa5e16b23e567c08365c903b7b1d Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Fri, 30 Nov 2018 11:15:27 +0000 Subject: [PATCH] Get rid of keys() usage for x in some_dict.keys() can be written as for x in some_dict Change-Id: If5436647a30c02d0dab7daa23b2290456c66d654 --- horizon/base.py | 2 +- openstack_auth/policy.py | 2 +- openstack_dashboard/dashboards/identity/domains/workflows.py | 2 +- openstack_dashboard/dashboards/identity/projects/workflows.py | 2 +- openstack_dashboard/test/unit/api/test_cinder.py | 2 +- openstack_dashboard/test/unit/api/test_nova.py | 2 +- openstack_dashboard/utils/config_types.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/horizon/base.py b/horizon/base.py index 2fe3bffc76..b14652165f 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -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] diff --git a/openstack_auth/policy.py b/openstack_auth/policy.py index 9f7f8d867f..d01a170a1c 100644 --- a/openstack_auth/policy.py +++ b/openstack_auth/policy.py @@ -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) diff --git a/openstack_dashboard/dashboards/identity/domains/workflows.py b/openstack_dashboard/dashboards/identity/domains/workflows.py index acf3dab4f5..742c49e489 100644 --- a/openstack_dashboard/dashboards/identity/domains/workflows.py +++ b/openstack_dashboard/dashboards/identity/domains/workflows.py @@ -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 diff --git a/openstack_dashboard/dashboards/identity/projects/workflows.py b/openstack_dashboard/dashboards/identity/projects/workflows.py index 2b898e9640..4323481a91 100644 --- a/openstack_dashboard/dashboards/identity/projects/workflows.py +++ b/openstack_dashboard/dashboards/identity/projects/workflows.py @@ -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 diff --git a/openstack_dashboard/test/unit/api/test_cinder.py b/openstack_dashboard/test/unit/api/test_cinder.py index da4da0e9a1..be714c5a8d 100644 --- a/openstack_dashboard/test/unit/api/test_cinder.py +++ b/openstack_dashboard/test/unit/api/test_cinder.py @@ -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() diff --git a/openstack_dashboard/test/unit/api/test_nova.py b/openstack_dashboard/test/unit/api/test_nova.py index 59903bbf6c..a0a042c2f9 100644 --- a/openstack_dashboard/test/unit/api/test_nova.py +++ b/openstack_dashboard/test/unit/api/test_nova.py @@ -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) diff --git a/openstack_dashboard/utils/config_types.py b/openstack_dashboard/utils/config_types.py index 10a50d0459..2a85bbec12 100644 --- a/openstack_dashboard/utils/config_types.py +++ b/openstack_dashboard/utils/config_types.py @@ -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):