Reputation: 31
I have a .proto
file that defines a message with a map<string, string>
field:
syntax = "proto3";
message Message {
map<string, string> map = 1;
}
After generating the Python code using buf
, the map
field is represented as RepeatedCompositeFieldContainer
instead of a ScalarMap. Here is the generated Python code for the message:
class ExchangeAuthzCodeRequest(google.protobuf.message.Message):
...
@property
def access_token_vars(self) -> google.protobuf.internal.containers.ScalarMap[str, str]:
...
When I print the type of the access_token_vars
field, I get:
print(type(proto_msg.access_token_vars))
# Output: <class 'google.protobuf.internal.containers.RepeatedCompositeFieldContainer'>
map<string, string>
field represented as RepeatedCompositeFieldContainer
in the generated Python code and not as ScalarMap?I'm using protobuf
version 4.25.3
I'm using mypy-protobuf version I'm using is 3.5.0
My buf configurations:
version: v1
plugins:
- name: python
out: .
- name: mypy
out: .
- name: grpclib_python
out: .
Upvotes: 1
Views: 107