Skip to content

Commit

Permalink
serialize tuple as tuple
Browse files Browse the repository at this point in the history
Signed-off-by: dafnapension <dafnashein@yahoo.com>
  • Loading branch information
dafnapension committed Feb 7, 2024
1 parent 960a4d7 commit b2a4959
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/unitxt/dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,12 @@ def _asdict_inner(obj):
if isinstance(obj, tuple) and hasattr(obj, "_fields"): # named tuple
return type(obj)(*[_asdict_inner(v) for v in obj])

if isinstance(obj, (list, tuple)):
if isinstance(obj, (list)):
return type(obj)([_asdict_inner(v) for v in obj])

if isinstance(obj, (tuple)):
return type(obj)(_asdict_inner(v) for v in obj)

if isinstance(obj, dict):
return type(obj)({_asdict_inner(k): _asdict_inner(v) for k, v in obj.items()})

Expand Down

0 comments on commit b2a4959

Please sign in to comment.