Open dechamps opened 4 months ago
I'm considering this https://github.com/trim21/transmission-rpc/pull/422
This method should raise KeyError if files
not fetched.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 77.64%. Comparing base (
57c064f
) to head (74d862b
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I'm considering this #422
I commented on that PR - I don't think it makes sense to force users to fetch fields they don't need.
This method should raise KeyError if
files
not fetched.
I agree that would make sense. Would you like me to extend this PR to also raise KeyError
if files
is not present?
I'm considering this #422
I commented on that PR - I don't think it makes sense to force users to fetch fields they don't need.
This method should raise KeyError if
files
not fetched.I agree that would make sense. Would you like me to extend this PR to also raise
KeyError
iffiles
is not present?
both sounds reasonable to me. But I plan to make breaking change when tr 4.1.0 is release.
Would mind update PR and wait until tr 4.1.0 is released? I'll merge it then.
I plan to make breaking change when tr 4.1.0 is release
I'm not sure why you see this as a breaking change? With the previous code the only way to get get_files()
to work and give the correct output was to fetch files
, properties
and wanted
. This PR does not change the behavior in that case. It only changes the behavior for usage patterns where the previous code did not work at all in the first place. Can't break what's already broken.
Would mind update PR
I have updated the PR to make get_files()
raise KeyError
if files
was not fetched.
Adjusted the PR to account for CI failures, which I didn't notice until now because it didn't run on my development branch (see #448 about that).
I plan to make breaking change when tr 4.1.0 is release
I'm not sure why you see this as a breaking change? With the previous code the only way to get
get_files()
to work and give the correct output was to fetchfiles
,properties
andwanted
. This PR does not change the behavior in that case. It only changes the behavior for usage patterns where the previous code did not work at all in the first place. Can't break what's already broken.
obviously it will throw KeyError
now
obviously it will throw
KeyError
now
It will not throw KeyError
in code that is not already broken.
If a caller called this method without fetching files
first, the previous code would return an incorrect result (i.e. an empty list). Meaning it's already broken.
The new code takes this already broken case and breaks it in a different, clearer way, by raising an error.
Caller code that is correct (i.e. callers who fetch files
before calling get_files()
) will not be broken by this change. The change only breaks callers that are already broken in the first place.
obviously it will throw
KeyError
nowIt will not throw
KeyError
in code that is not already broken.If a caller called this method without fetching
files
first, the previous code would return an incorrect result (i.e. an empty list). Meaning it's already broken.The new code takes this already broken case and breaks it in a different, clearer way, by raising an error.
Caller code that is correct (i.e. callers who fetch
files
before callingget_files()
) will not be broken by this change. The change only breaks callers that are already broken in the first place.
I get your point. To be honest, I had same conversation in some other repos with their maintainer.
And yes, you are right. calling .files()
without files
field fetched is actually not valid call, but changing it to raise a execption will have control flow problem.
Consider a long running script just call files and iter it, without try/catch.
It may get broken by this change, and I want to avoid this.
Also, there is already a in-plan breaking change so make a change like this in a non-major version change sounds like a realy bad idea to me.
BREAKING CHANGE:
torrent.get_files()
will raise a KeyError if fieldfiles
not fetched.file.priority
andfile.selected
are not optional, based on fields fetched.