File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -569,6 +569,10 @@ def annotation(self) -> str:
569
569
570
570
@dataclass
571
571
class OneOfFieldCompiler (FieldCompiler ):
572
+ @property
573
+ def optional (self ) -> bool :
574
+ return True
575
+
572
576
@property
573
577
def betterproto_field_args (self ) -> List [str ]:
574
578
args = super ().betterproto_field_args
@@ -579,13 +583,6 @@ def betterproto_field_args(self) -> List[str]:
579
583
580
584
@dataclass
581
585
class PydanticOneOfFieldCompiler (OneOfFieldCompiler ):
582
- @property
583
- def optional (self ) -> bool :
584
- # Force the optional to be True. This will allow the pydantic dataclass
585
- # to validate the object correctly by allowing the field to be let empty.
586
- # We add a pydantic validator later to ensure exactly one field is defined.
587
- return True
588
-
589
586
@property
590
587
def pydantic_imports (self ) -> Set [str ]:
591
588
return {"model_validator" }
You can’t perform that action at this time.
0 commit comments