danielgtaylor / python-betterproto

Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
MIT License
1.53k stars 214 forks source link

SerializeToString Error for `List of List` #541

Closed jhonsonlaid closed 11 months ago

jhonsonlaid commented 11 months ago

Summary

SerializeToString Error for List of List

Reproduction Steps

kps.proto

syntax = "proto3";

package kps;

message JointData {
    repeated float data = 1;
}

message KpsResponse{
    repeated JointData BodyData = 1;
}

run


d = JointData([2.1, 3.2])
print(d.SerializeToString())  # right

x =  np.random.randn(2, 3).tolist()
y = KpsResponse(body_data=x)  
print(y.SerializeToString()) # error

Expected Results

successfully serialized

Actual Results

TypeError: 'float' object cannot be interpreted as an integer

System Information

libprotoc 24.3 python 3.7.13 betterproto 2.0.0b6

Checklist

Gobot1234 commented 11 months ago

This wouldn't be supported by the google implementation and won't be by betterproto as you are violating the types required to be passed. Instead of passing a list pass an instance of JointData to body_data