Handle empty value objects properly (#481)

Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>
This commit is contained in:
Ollie
2023-06-24 20:19:13 +01:00
committed by GitHub
parent a7532bbadc
commit 182aedaec4
3 changed files with 31 additions and 7 deletions

View File

@@ -704,6 +704,13 @@ class Message(ABC):
return value
def __setattr__(self, attr: str, value: Any) -> None:
if (
isinstance(value, Message)
and hasattr(value, "_betterproto")
and not value._betterproto.meta_by_field_name
):
value._serialized_on_wire = True
if attr != "_serialized_on_wire":
# Track when a field has been set.
self.__dict__["_serialized_on_wire"] = True