Closed
Description
This oneof
definition generates valid Python code, but later it is not possible to parse or create an instance of TileValue
because the name of the field is the same as the type. Should betterproto rename such fields automatically, or at least throw an error during the code generation? I spent considerable time trying to understand why this line was saying t
is not a class:
python-betterproto/betterproto/__init__.py
Line 594 in 3546f55
message Tile {
message Value {
oneof val {
string string = 1;
float float = 2;
double double = 3;
int64 int = 4;
uint64 uint = 5;
sint64 sint = 6;
bool bool = 7;
}
}
repeated Value values = 1;
}
@dataclass
class Tile(betterproto.Message):
values: List["TileValue"] = betterproto.message_field(1)
@dataclass
class TileValue(betterproto.Message):
string: str = betterproto.string_field(1, group="val")
float: float = betterproto.float_field(2, group="val")
double: float = betterproto.double_field(3, group="val")
int: int = betterproto.int64_field(4, group="val")
uint: int = betterproto.uint64_field(5, group="val")
sint: int = betterproto.sint64_field(6, group="val")
bool: bool = betterproto.bool_field(7, group="val")