Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

cheeseandcereal
Copy link
Contributor

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'>

Signed-off-by: Adam Crowder <adam@adamcrowder.net>
@cheeseandcereal cheeseandcereal changed the title Fix consistency with double [float] number type parsing fix: Correct consistency with double [float] number type parsing Jul 16, 2024
Copy link

codecov bot commented Jul 16, 2024

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 ⚠️
transmission_rpc/client.py 0.00% 1 Missing ⚠️
transmission_rpc/session.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #457   +/-   ##
=======================================
  Coverage   77.67%   77.67%           
=======================================
  Files          14       14           
  Lines        1505     1505           
=======================================
  Hits         1169     1169           
  Misses        336      336           
Flag Coverage Δ
3.10 77.67% <0.00%> (ø)
3.11 77.67% <0.00%> (ø)
3.12 77.67% <0.00%> (ø)
3.8 77.47% <0.00%> (ø)
3.9 77.47% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trim21 trim21 merged commit 113716b into trim21:master Jul 16, 2024
20 of 22 checks passed
@cheeseandcereal cheeseandcereal deleted the fix_float_types branch July 16, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent number types of certain float-typed properties
2 participants