Python protobuf>3.20.0 well known types wrappers(can't find a way to use Int32Value, StringValue, Empty and more)

205 views
Skip to first unread message

Greg Alelov

unread,
Jan 26, 2023, 9:05:44 AM1/26/23
to Protocol Buffers
Hey guys,
We're using Java(protobuf-java:3.21.7)[Everything works fine there] and Python in our projects

I've encountered a weird problem in Python after moving to any version above 3.19.4 we couldn't use the well known types such as  Int32Value, StringValue and more.

the import(working in version 3.19.4):
from google.protobuf.wrappers_pb2 import Int32Value

example of usage(Working in version 3.19.4):
response = stub.GetData(Int32Value(value=int(data_id)), metadata=[('account_id', account_id)])

when upgrading to 3.20.0 or above it seems like the import doesn't work anymore and that the ide can't find these well known types(according to:  https://protobuf.dev/reference/protobuf/google.protobuf/  ) in the protobuf library at all.
(Looked everywhere in the package and couldn't find it).

The proto part that works in 3.19.4 looks like this:
service DataService{
rpc GetData(google.protobuf.Int32Value) returns (Data){};

Is there another way to use the google built in .proto files wrappers(In python) of well known types?

The answer in the thread attached didn't help us(The example sent in the post there doesn't contain the wrappers for string, int etc):
https://groups.google.com/g/protobuf/c/B0lNTTLZZdA?pli=1
Reply all
Reply to author
Forward
0 new messages