trim21 / transmission-rpc

https://transmission-rpc.readthedocs.io/en/stable/
MIT License
145 stars 34 forks source link

fix: Correct consistency with double [float] number type parsing #457

Closed cheeseandcereal closed 3 months ago

cheeseandcereal commented 3 months ago

Description

Fixes #456

This PR fixes 'double' number type parsing, by ensuring that all values documented/intended as 'doubles' in the transmission RPC are returned as 'float's by this library (as they're already currently correctly documented).

This fixes the issue of unintentionally returning 'int' types for these functions which document 'float' return types when the return value is a whole number (particularly 0 or 1). Some functions in the library already did this, but not all of them, so this PR fixes this inconsistency.

See the upstream transmission documentation for all parameters which are a 'double' value type which should be returned as 'float's by this library: https://github.com/transmission/transmission/blob/main/docs/rpc-spec.md

Testing

I ran all tests (task lint and task test [note, an __init__.py file needed to be added to the tests/ directory for task test to work]) as well as did a basic sanity check against live usage of this package after these changes.

Before these changes:

type(client.get_torrents()[0].percent_done)
<class 'int'>

After these changes:

type(client.get_torrents()[0].percent_done)
<class 'float'>
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 77.67%. Comparing base (57c064f) to head (8950f10). Report is 40 commits behind head on master.

Files with missing lines Patch % Lines
transmission_rpc/torrent.py 0.00% 6 Missing :warning:
transmission_rpc/client.py 0.00% 1 Missing :warning:
transmission_rpc/session.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #457 +/- ## ======================================= Coverage 77.67% 77.67% ======================================= Files 14 14 Lines 1505 1505 ======================================= Hits 1169 1169 Misses 336 336 ``` | [Flag](https://app.codecov.io/gh/trim21/transmission-rpc/pull/457/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21) | Coverage Δ | | |---|---|---| | [3.10](https://app.codecov.io/gh/trim21/transmission-rpc/pull/457/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21) | `77.67% <0.00%> (ø)` | | | [3.11](https://app.codecov.io/gh/trim21/transmission-rpc/pull/457/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21) | `77.67% <0.00%> (ø)` | | | [3.12](https://app.codecov.io/gh/trim21/transmission-rpc/pull/457/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21) | `77.67% <0.00%> (ø)` | | | [3.8](https://app.codecov.io/gh/trim21/transmission-rpc/pull/457/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21) | `77.47% <0.00%> (ø)` | | | [3.9](https://app.codecov.io/gh/trim21/transmission-rpc/pull/457/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21) | `77.47% <0.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Trim21#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.