10000 Fix enum compilation · AdrienVannson/python-betterproto@fd0bf4c · GitHub
[go: up one dir, main page]

Skip to content

Commit fd0bf4c

Browse files
committed
Fix enum compilation
1 parent 8b7a947 commit fd0bf4c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/betterproto/plugin/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ def betterproto_field_args(self) -> List[str]:
450450
if self.field_wraps:
451451
args.append(f"wraps={self.field_wraps}")
452452
if self.optional:
453-
args.append(f"optional=True")
453+
args.append("optional=True")
454454
if self.repeated:
455-
args.append(f"repeated=True")
455+
args.append("repeated=True")
456+
if self.field_type == "enum":
457+
args.append(f"enum_default_value=lambda: {self.py_type.strip('"')}.try_value(0)")
456458
return args
457459

458460
@property

0 commit comments

Comments
 (0)
0