From 2ac87cbc3d218dd9816daca388c861b5a784ed3d Mon Sep 17 00:00:00 2001 From: bhagyashris Date: Fri, 26 Aug 2016 16:29:52 +0530 Subject: [PATCH] Replace functions 'Dict.get' and 'del' with 'Dict.pop' Refactoring code: Making 'kwargs' dict to use single instruction: pop() rather than two instructions: get() and del, giving the codes a format that carries through. TrivialFix Change-Id: I2b2221e92495beb88be8feb76adbc4d756a180f2 --- heatclient/openstack/common/apiclient/client.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/heatclient/openstack/common/apiclient/client.py b/heatclient/openstack/common/apiclient/client.py index 24c6e731..87337726 100644 --- a/heatclient/openstack/common/apiclient/client.py +++ b/heatclient/openstack/common/apiclient/client.py @@ -145,13 +145,10 @@ class HTTPClient(object): resp.text) def serialize(self, kwargs): - if kwargs.get('json') is not None: + json_data = kwargs.pop('json', None) + if json_data is not None: kwargs['headers']['Content-Type'] = 'application/json' - kwargs['data'] = json.dumps(kwargs['json']) - try: - del kwargs['json'] - except KeyError: - pass + kwargs['data'] = json.dumps(json_data) def get_timings(self): return self.times