-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas testHas a (xfail) test that verifies the bugfix or featureHas a (xfail) test that verifies the bugfix or featuresmallLow effort issue that can easily be picked upLow effort issue that can easily be picked up
Milestone
Description
Protobuf spec file like this:
syntax = "proto3";
package message;
message TeraMessage {
int64 timestamp = 1;
enum MessageType {
MESSAGE_TYPE_UNKNOWN = 0;
MESSAGE_TYPE_ACTION_MESSAGE = 1;
// @exclude MESSAGE_TYPE_COMMAND_MESSAGE = 2; // DEPRECATED
MESSAGE_TYPE_CONFIG_MESSAGE = 3;
MESSAGE_TYPE_HEARTBEAT_MESSAGE = 4;
}
MessageType message_type = 5;
bytes message = 6;
}
Generates the following Python bindings:
from dataclasses import dataclass
import betterproto
class TeraMessageMessageType(betterproto.Enum):
MESSAGE_TYPE_UNKNOWN = 0
MESSAGE_TYPE_ACTION_MESSAGE = 1
# NB: notice that 2 is missing
MESSAGE_TYPE_CONFIG_MESSAGE = 3
MESSAGE_TYPE_HEARTBEAT_MESSAGE = 4
@dataclass
class TeraMessage(betterproto.Message):
timestamp: int = betterproto.int64_field(1)
message_type: "TeraMessageMessageType" = betterproto.enum_field(5)
message: bytes = betterproto.bytes_field(6)
To reproduce the bug:
>>> from my.path.message import TeraMessage, TeraMessageMessageType
>>> message = TeraMessage(message_type=TeraMessageMessageType.MESSAGE_TYPE_CONFIG_MESSAGE)
>>> message.to_dict()
{'messageType': 'MESSAGE_TYPE_HEARTBEAT_MESSAGE'}
>>> message.to_json()
'{"messageType": "MESSAGE_TYPE_HEARTBEAT_MESSAGE"}'
>>> TeraMessage().parse(bytes(message)).message_type == TeraMessageMessageType.MESSAGE_TYPE_CONFIG_MESSAGE
True
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas testHas a (xfail) test that verifies the bugfix or featureHas a (xfail) test that verifies the bugfix or featuresmallLow effort issue that can easily be picked upLow effort issue that can easily be picked up