danielgtaylor / danielgtaylor/python-betterproto

from_dict() does not cast floating point types

Open
#96 1 comment 0 reactions 0 assignees View on GitHub
bug good first issue low priority small
Dominant language
Python
Stars
1.8k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start in betterproto/__init__.py at line 890 and trace from_dict() handling for integer and floating-point fields. Confirm the expected reverse conversion, then verify that integer inputs produce float-valued fields without changing the existing integer conversion behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.