Stop using .keys() on dicts where not needed

Iterating over a dict results in the keys.

Using the 'in' operator on a dict checks if it's a key.

Change-Id: I6affbfa1a79a9e8c0b5b304078a7a8e4e792eecd
This commit is contained in:
Brant Knudson
2015-06-23 19:45:57 -05:00
parent eae8e83f5a
commit b54d9f122c
5 changed files with 7 additions and 7 deletions

View File

@@ -218,7 +218,7 @@ class AuthMethod(object):
setattr(self, param, kwargs.pop(param, None))
if kwargs:
msg = _("Unexpected Attributes: %s") % ", ".join(kwargs.keys())
msg = _("Unexpected Attributes: %s") % ", ".join(kwargs)
raise AttributeError(msg)
@classmethod

View File

@@ -579,7 +579,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
Returns a slash-separated string of values ordered by key name.
"""
return '/'.join([kwargs[k] or '?' for k in sorted(kwargs.keys())])
return '/'.join([kwargs[k] or '?' for k in sorted(kwargs)])
def get_auth_ref_from_keyring(self, **kwargs):
"""Retrieve auth_ref from keyring.

View File

@@ -130,7 +130,7 @@ class Session(object):
if not session:
session = requests.Session()
# Use TCPKeepAliveAdapter to fix bug 1323862
for scheme in session.adapters.keys():
for scheme in session.adapters:
session.mount(scheme, TCPKeepAliveAdapter())
self.auth = auth
@@ -682,7 +682,7 @@ class Session(object):
pass
if params_copy:
raise exceptions.UnsupportedParameters(list(params_copy.keys()))
raise exceptions.UnsupportedParameters(list(params_copy))
return params

View File

@@ -59,8 +59,8 @@ class SimpleReadOnlyKeystoneClientTest(base.ClientTestBase):
# check that region and publicURL exists. One might also
# check for adminURL and internalURL. id seems to be optional
# and is missing in the catalog backend
self.assertIn('publicURL', svc.keys())
self.assertIn('region', svc.keys())
self.assertIn('publicURL', svc)
self.assertIn('region', svc)
def test_admin_endpoint_list(self):
out = self.keystone('endpoint-list')

View File

@@ -54,7 +54,7 @@ class MemcacheCryptPositiveTests(testtools.TestCase):
len(keys['MAC']))
self.assertNotEqual(keys['ENCRYPTION'],
keys['MAC'])
self.assertIn('strategy', keys.keys())
self.assertIn('strategy', keys)
def test_key_strategy_diff(self):
k1 = self._setup_keys(b'MAC')