python-betterproto
python-betterproto copied to clipboard
Protoc proto file , AccountInfo -> CcountInfo, why and how to solve
message LoginInfo { optional string login_channel = 1; optional string open_id = 2; // optional DeviceInfo deviceInfo = 3; optional AccountInfo accountInfo = 4; optional int64 robotIntoId = 5; }
@dataclass class LoginInfo(betterproto.Message): login_channel: str = betterproto.string_field(1) open_id: str = betterproto.string_field(2) device_info: "DeviceInfo" = betterproto.message_field(3) account_info: "CcountInfo" = betterproto.message_field(4) robot_into_id: int = betterproto.int64_field(5)
What version of betterproto are you using that does this? I can't reproduce this bug
cat test.proto
message AccountInfo {}
message DeviceInfo {}
message LoginInfo {
optional string login_channel = 1;
optional string open_id = 2; //
optional DeviceInfo deviceInfo = 3;
optional AccountInfo accountInfo = 4;
optional int64 robotIntoId = 5;
}
protoc -I . --python_betterproto_out=lib test.proto
[libprotobuf WARNING google/protobuf/compiler/parser.cc:646] No syntax specified for the proto file: test.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
Writing __init__.py
cat lib/__init__.py
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: test.proto
# plugin: python-betterproto
from dataclasses import dataclass
import betterproto
@dataclass(eq=False, repr=False)
class AccountInfo(betterproto.Message):
pass
@dataclass(eq=False, repr=False)
class DeviceInfo(betterproto.Message):
pass
@dataclass(eq=False, repr=False)
class LoginInfo(betterproto.Message):
login_channel: str = betterproto.string_field(1)
open_id: str = betterproto.string_field(2)
device_info: "DeviceInfo" = betterproto.message_field(3)
account_info: "AccountInfo" = betterproto.message_field(4)
robot_into_id: int = betterproto.int64_field(5)
1.2.5
many proto files exist this problem
I probably know the problem. I use proto2. Is there any way to solve it
After I changed to proto3, the problem still exists
When I change betterproto 2.0.0b5, I will report the following mistakes
When I change it, I will report the following mistakes
Can you try using the commands suggested in the README? it seemed very parsable to my protoc