danielgtaylor / python-betterproto

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

from_dict() does not cast floating point types #96

Open priesgo opened 4 years ago

priesgo commented 4 years ago

When you pass in the dictionary a float to an int field, this is casted to int (line 890 betterproto/__init__.py). I would expect a similar behaviour in the reverse situation when you pass an int to a float field. Right now you end up with an object having an int in a field which should contain a float.

boukeversteegh commented 4 years ago

Hey Pablo! Sorry for the late reply to your issue.

We have had some bugs before with ints and floats, but it turns out the specific protobuf types matter.

Which protobuf types should cast to an int? Or if you could please update your link (as our code has changed)?

You can open a file on github, select the line and copy the link. Thanks!