]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
More compact expression with dict.get()
authorAron Griffis <aron@arongriffis.com>
Mon, 24 Aug 2015 18:22:12 +0000 (14:22 -0400)
committerAron Griffis <aron@arongriffis.com>
Mon, 24 Aug 2015 20:19:34 +0000 (16:19 -0400)
vcr/filters.py

index 102a95ebcc85f056f5fb09bd17d2df858eb16d61..10830c636cde7da15e9506bd1037f21ee5b06c39 100644 (file)
@@ -27,8 +27,7 @@ def remove_query_parameters(request, query_parameters_to_remove):
 
 def remove_post_data_parameters(request, post_data_parameters_to_remove):
     if request.method == 'POST' and not isinstance(request.body, BytesIO):
-        if ('Content-Type' in request.headers and
-                request.headers['Content-Type'] == 'application/json'):
+        if request.headers.get('Content-Type') == 'application/json':
             json_data = json.loads(request.body.decode('utf-8'))
             for k in list(json_data.keys()):
                 if k in post_data_parameters_to_remove: