danielgtaylor / danielgtaylor/python-betterproto
Gracefully handle encoding of different number types
Open
bug
good first issue
high priority
small
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
If a float is set on a Message field of type int then an exception is raised when serialising. Floats and ints are largely interchangeable in python3, so maybe betterproto should handle this more gracefully, by for example: casting to int or float as appropriate before encoding.
The resulting error message includes:
```
unsupported operand type(s) for &: 'float' and 'int'
```
Contributor guide
Assessment
This issue has not been assessed yet.