I'm writing pybindngs for a C++ class that has Google Protobuf objects as member variables. I'd like these binded-functions to return (in Python land) the Python version of the protobuf object (which Google's proto compiler natively generates).
If I try and naively return the C++ version of the protobuf in the pybind definition
.def_readwrite("my_protobuf", &my_protobuf_)
, I get the following error:
TypeError: Unable to convert function return value to a Python type! The signature was
(self: MyClass) -> MyProtobufDef
which makes sense - the return type is a C++ protobuf object, not the Python protobuf object. How do I convert this into the Python version of the protobuf?