-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Labels
Description
Summary
When I create a contract with a repeated int64 variable, it serializes into repeated string, which is an unpredictable behaviour
Reproduction Steps
- Create a contract:
// ExampleContract describes example of contract.
message ExampleContract {
// List of int64.
repeated int64 items = 1;
// Default int64 value.
google.protobuf.Int64Value default = 2;
}- Compile to python:
@dataclass(eq=False, repr=False)
class ExampleContract(betterproto.Message):
"""
ExampleContract describes example of contract.
"""
items: List[int] = betterproto.int64_field(1)
"""List of int64."""
default: Optional[int] = betterproto.message_field(2, wraps=betterproto.TYPE_INT64)
"""Default int64 value."""
- Create instance of class and serialize it to JSON:
ec = ExampleContract(items=[5, 10], default=10)
print(ec.to_json())
Expected Results
{"items": [5, 10], "default": 10}
Actual Results
{"items": ["5", "10"], "default": 10}
System Information
libprotoc 25.3, Python 3.12.7
Name: betterproto
Version: 2.0.0b7
Summary: A better Protobuf / gRPC generator & library
Home-page: https://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: danielgtaylor@gmail.com
License: MIT
Location: /opt/conda/lib/python3.12/site-packages
Requires: grpclib, python-dateutil, typing-extensions
Checklist
- I have searched the issues for duplicates.
- I have shown the entire traceback, if possible.
- I have verified this issue occurs on the latest prelease of betterproto which can be installed using
pip install -U --pre betterproto, if possible.