Skip to content

Commit a31d1be

Browse files
Fix optional (#19)
1 parent cbb0f65 commit a31d1be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/betterproto/plugin/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ def repeated(self) -> bool:
457457

458458
@property
459459
def optional(self) -> bool:
460-
return self.proto_obj.proto3_optional or self.field_type == "message"
460+
return self.proto_obj.proto3_optional or (
461+
self.field_type == "message" and not self.repeated
462+
)
461463

462464
@property
463465
def field_type(self) -> str:

0 commit comments

Comments
 (0)