From 029b51d37899518f1cdc40a737394fdfd6771df5 Mon Sep 17 00:00:00 2001 From: Ankit Agrawal Date: Thu, 24 Sep 2015 00:00:25 -0700 Subject: [PATCH] Use dictionary literal for dictionary creation Dictionary creation could be rewritten as a dictionary literal. for example: body = {} body['provider'] = args.provider could be rewritten as body = {'provider': args.provider} TrivialFix Change-Id: Ieae7b33332eca31754cbfe91288ef3001c573eb3 --- cinderclient/tests/unit/test_client.py | 11 ++++++----- cinderclient/v1/shell.py | 11 ++++++----- cinderclient/v2/shell.py | 14 +++++++------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/cinderclient/tests/unit/test_client.py b/cinderclient/tests/unit/test_client.py index 2ce2bc60d..ff5e6d923 100644 --- a/cinderclient/tests/unit/test_client.py +++ b/cinderclient/tests/unit/test_client.py @@ -49,11 +49,12 @@ class ClientTest(utils.TestCase): ) ) - kwargs = {} - kwargs['headers'] = {"X-Foo": "bar"} - kwargs['data'] = ('{"auth": {"tenantName": "fakeService",' - ' "passwordCredentials": {"username": "fakeUser",' - ' "password": "fakePassword"}}}') + kwargs = { + 'headers': {"X-Foo": "bar"}, + 'data': ('{"auth": {"tenantName": "fakeService",' + ' "passwordCredentials": {"username": "fakeUser",' + ' "password": "fakePassword"}}}') + } cs = cinderclient.client.HTTPClient("user", None, None, "http://127.0.0.1:5000") diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index e90cd66c2..3896ac3ab 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -1225,11 +1225,12 @@ def do_encryption_type_create(cs, args): """Creates encryption type for a volume type. Admin only.""" volume_type = _find_volume_type(cs, args.volume_type) - body = {} - body['provider'] = args.provider - body['cipher'] = args.cipher - body['key_size'] = args.key_size - body['control_location'] = args.control_location + body = { + 'provider': args.provider, + 'cipher': args.cipher, + 'key_size': args.key_size, + 'control_location': args.control_location + } result = cs.volume_encryption_types.create(volume_type, body) _print_volume_encryption_type_list([result]) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index ee5de767f..16e6877c1 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -1660,11 +1660,12 @@ def do_encryption_type_create(cs, args): """Creates encryption type for a volume type. Admin only.""" volume_type = _find_volume_type(cs, args.volume_type) - body = {} - body['provider'] = args.provider - body['cipher'] = args.cipher - body['key_size'] = args.key_size - body['control_location'] = args.control_location + body = { + 'provider': args.provider, + 'cipher': args.cipher, + 'key_size': args.key_size, + 'control_location': args.control_location + } result = cs.volume_encryption_types.create(volume_type, body) _print_volume_encryption_type_list([result]) @@ -2011,8 +2012,7 @@ def do_manage(cs, args): volume_metadata = _extract_metadata(args) # Build a dictionary of key/value pairs to pass to the API. - ref_dict = {} - ref_dict[args.id_type] = args.identifier + ref_dict = {args.id_type: args.identifier} # The recommended way to specify an existing volume is by ID or name, and # have the Cinder driver look for 'source-name' or 'source-id' elements in