Converts protobuf generated messages to Python friendly schematics models.
Making Protobuf messages as cute as Python.
Protobuf and gRPC are great when it comes to high performance schema aware APIs, but when Google designed Protobuf, it didn’t tried to make the generated code idiomatic in Python, which brings a problem when exporting messages outside iterface modules.
Schematics is a cute and pythonic schema library. Why not join both?
pip install proto_schamatics
Inspecting a module is as simple as:
from proto_schematics import ProtobufModule models = ProtobufModule('my_protobuf_lib').import_schema() MySchamticsModel = models['ProtobufMessageName']
You can also do it on a lazy lint unfriendly way:
from proto_schematics import ProtobufModule ProtobufModule('my_protobuf_lib').meta_import() from protobuf_schematics import ProtobufMessageName as MySchematicsModel
- Datetimes as native Python
- Duration as TimeDeltas
- Wrappers as native nullable types