diff --git a/resources/lib/dropbox/oauth.py b/resources/lib/dropbox/oauth.py index be46b40..c51f870 100644 --- a/resources/lib/dropbox/oauth.py +++ b/resources/lib/dropbox/oauth.py @@ -511,9 +511,5 @@ def _params_to_urlencoded(params): else: return str(o).encode('utf-8') - #fix for python 2.6 - utf8_params = {} - for k,v in six.iteritems(params): - utf8_params[encode(k)] = encode(v) - + utf8_params = {encode(k): encode(v) for k, v in six.iteritems(params)} return url_encode(utf8_params) diff --git a/resources/lib/dropbox/stone_serializers.py b/resources/lib/dropbox/stone_serializers.py index 3fe68b1..e4be3fa 100644 --- a/resources/lib/dropbox/stone_serializers.py +++ b/resources/lib/dropbox/stone_serializers.py @@ -237,12 +237,11 @@ class StoneToPythonPrimitiveSerializer(StoneSerializerBase): def encode_map(self, validator, value): validated_value = validator.validate(value) - #fix for python 2.6 - result = {} - for key, value in validated_value.items(): - result[self.encode_sub(validator.key_validator,key)] = self.encode_sub(validator.value_validator, value) - - return result + return { + self.encode_sub(validator.key_validator, key): + self.encode_sub(validator.value_validator, value) for + key, value in validated_value.items() + } def encode_nullable(self, validator, value): if value is None: @@ -831,12 +830,11 @@ def _decode_list( if not isinstance(obj, list): raise bv.ValidationError( 'expected list, got %s' % bv.generic_type_name(obj)) - - result = [] - for item in obj: - result.append(_json_compat_obj_decode_helper(data_type.item_validator, item, alias_validators, strict,old_style, for_msgpack)) - - return result + return [ + _json_compat_obj_decode_helper( + data_type.item_validator, item, alias_validators, strict, + old_style, for_msgpack) + for item in obj] def _decode_map( @@ -848,12 +846,15 @@ def _decode_map( if not isinstance(obj, dict): raise bv.ValidationError( 'expected dict, got %s' % bv.generic_type_name(obj)) - - result = {} - for key, value in obj.items(): - result[_json_compat_obj_decode_helper(data_type.key_validator, key, alias_validators, strict,old_style, for_msgpack)] = _json_compat_obj_decode_helper(data_type.value_validator, value, alias_validators, strict,old_style, for_msgpack) - - return result + return { + _json_compat_obj_decode_helper( + data_type.key_validator, key, alias_validators, strict, + old_style, for_msgpack): + _json_compat_obj_decode_helper( + data_type.value_validator, value, alias_validators, strict, + old_style, for_msgpack) + for key, value in obj.items() + } def _decode_nullable( diff --git a/resources/lib/dropbox/stone_validators.py b/resources/lib/dropbox/stone_validators.py index 3e9bc22..f919dc7 100644 --- a/resources/lib/dropbox/stone_validators.py +++ b/resources/lib/dropbox/stone_validators.py @@ -422,13 +422,10 @@ class Map(Composite): def validate(self, val): if not isinstance(val, dict): raise ValidationError('%r is not a valid dict' % val) - - #fix for python 2.6 - result = {} - for key, value in val.items(): - result[self.key_validator.validate(key)] = self.value_validator.validate(value) - - return result + return { + self.key_validator.validate(key): + self.value_validator.validate(value) for key, value in val.items() + } class Struct(Composite):