Inconsistent number types of certain float-typed properties
# Description
Due to the limitations of json, there is no distinction in the protocol for different types of numbers (i.e. float vs int)
This means that when parsing the response field of a number from the RPC, if it's a 'double' field (or documented as 'float' in this library), it may not always return a float. This typically happens when a 'double' number as defined in the rpc is either flat 0 or 1.
For example:
```python
type(client.get_torrents()[0].percent_done)
<class 'int'>
```
This is inconsistent with the documented types. I.e. for this example: https://github.com/trim21/transmission-rpc/blob/57c064f6b740b67be1ed7c5afad5ce18476616f4/transmission_rpc/torrent.py#L562
This _can_ result in some edge case issues where applications actually depend on this number to be of a particular type, and/or not flip between `int` and `float`
For any value that's documented as a float, this library should explicitly 'cast' it as a float to avoid this inconsistent typing.
i.e.
```python
return float(self.fields["percentDone"])
```
关闭于 2024-07-16 2 条评论