Skip to content

Commit

Permalink
cleanup(serializer): simplify duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithWittmann committed Nov 4, 2023
1 parent 731bca7 commit 5f07287
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions causy/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,14 @@ def _serialize_object(self, obj):
x.serialize() if isinstance(x, SerializeMixin) else x
for x in getattr(self, attr)
}
elif isinstance(getattr(self, attr), tuple):
elif isinstance(getattr(self, attr), tuple) or isinstance(
getattr(self, attr), set
):
# tuples are immutable, so we have to convert them to lists
result[attr] = [
x.serialize() if isinstance(x, SerializeMixin) else x
for x in getattr(self, attr)
]
elif isinstance(getattr(self, attr), set):
# sets are immutable, so we have to convert them to lists
result[attr] = [
x.serialize() if isinstance(x, SerializeMixin) else x
for x in getattr(self, attr)
]

return result

Expand Down

0 comments on commit 5f07287

Please sign in to comment.