Skip to content

Commit 4554d91

Browse files
authored
Exclude empty lists from to_dict output
1 parent 559b883 commit 4554d91

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

betterproto/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ def to_dict(self, casing: Casing = Casing.CAMEL) -> dict:
728728
elif isinstance(v, list):
729729
# Convert each item.
730730
v = [i.to_dict(casing) for i in v]
731-
output[cased_name] = v
731+
if v:
732+
output[cased_name] = v
732733
elif v._serialized_on_wire:
733734
output[cased_name] = v.to_dict(casing)
734735
elif meta.proto_type == "map":

0 commit comments

Comments
 (0)