@@ -33,11 +33,13 @@ def deserialize(self, raw_data: bytes) -> Metadata:
3333 """Deserialize utf-8 encoded JSON bytes into Metadata object. """
3434 try :
3535 json_dict = json .loads (raw_data .decode ("utf-8" ))
36- return Metadata .from_dict (json_dict )
36+ metadata_obj = Metadata .from_dict (json_dict )
3737
3838 except Exception as e : # pylint: disable=broad-except
3939 six .raise_from (DeserializationError , e )
4040
41+ return metadata_obj
42+
4143
4244class JSONSerializer (MetadataSerializer ):
4345 """A Metadata-to-JSON serialize method.
@@ -54,15 +56,17 @@ def serialize(self, metadata_obj: Metadata) -> bytes:
5456 """Serialize Metadata object into utf-8 encoded JSON bytes. """
5557 try :
5658 indent = (None if self .compact else 1 )
57- separators = ((',' , ':' ) if self .compact else (',' , ': ' ))
58- return json .dumps (metadata_obj .to_dict (),
59- indent = indent ,
60- separators = separators ,
61- sort_keys = True ).encode ("utf-8" )
59+ separators = ((',' , ':' ) if self .compact else (',' , ': ' ))
60+ json_bytes = json .dumps (metadata_obj .to_dict (),
61+ indent = indent ,
62+ separators = separators ,
63+ sort_keys = True ).encode ("utf-8" )
6264
6365 except Exception as e : # pylint: disable=broad-except
6466 six .raise_from (SerializationError , e )
6567
68+ return json_bytes
69+
6670
6771class CanonicalJSONSerializer (SignedSerializer ):
6872 """A Signed-to-Canonical JSON 'serialize' method. """
@@ -71,7 +75,9 @@ def serialize(self, signed_obj: Signed) -> bytes:
7175 """Serialize Signed object into utf-8 encoded Canonical JSON bytes. """
7276 try :
7377 signed_dict = signed_obj .to_dict ()
74- return encode_canonical (signed_dict ).encode ("utf-8" )
78+ canonical_bytes = encode_canonical (signed_dict ).encode ("utf-8" )
7579
7680 except Exception as e : # pylint: disable=broad-except
7781 six .raise_from (SerializationError , e )
82+
83+ return canonical_bytes
0 commit comments