Skip to content

Commit a61a3c8

Browse files
fix: lookup attribute instead of performing a deepcopy (#226)
* fix: lookup attribute instead of performing a deepcopy * address review feedback Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 133a332 commit a61a3c8

File tree

1 file changed

+7
-1
lines changed
  • packages/proto-plus/proto/marshal/collections

1 file changed

+7
-1
lines changed

packages/proto-plus/proto/marshal/collections/repeated.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ def _pb_type(self):
104104
if len(self.pb) > 0:
105105
return type(self.pb[0])
106106

107-
# We have no members in the list.
107+
# We have no members in the list, so we get the type from the attributes.
108+
if hasattr(self.pb, "_message_descriptor") and hasattr(
109+
self.pb._message_descriptor, "_concrete_class"
110+
):
111+
return self.pb._message_descriptor._concrete_class
112+
113+
# Fallback logic in case attributes are not available
108114
# In order to get the type, we create a throw-away copy and add a
109115
# blank member to it.
110116
canary = copy.deepcopy(self.pb).add()

0 commit comments

Comments
 (0)