-
Notifications
You must be signed in to change notification settings - Fork 35
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(torrent): get_files()
should throw KeyError
if files
not fetched
#446
Conversation
I'm considering this #422 This method should raise KeyError if |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #446 +/- ##
==========================================
- Coverage 77.67% 77.64% -0.03%
==========================================
Files 14 14
Lines 1505 1503 -2
==========================================
- Hits 1169 1167 -2
Misses 336 336
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I commented on that PR - I don't think it makes sense to force users to fetch fields they don't need.
I agree that would make sense. Would you like me to extend this PR to also raise |
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'm not sure why you see this as a breaking change? With the previous code the only way to get
I have updated the PR to make |
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). |
get_files()
should throw KeyError
if files
not fetched
This commit fixes the following issues with `Torrent.get_files()`: If Client.get_torrent() was called with "files" not in `arguments`, then `get_files()` returns an empty list. This is surprising - it should raise an error instead. If Client.get_torrent() was called with arguments=["files"], get_files() fails because it expects to find `properties` and `wanted`, which were not requested. For efficiency we should not force users to request fields they don't need, so leave these unset in this case.
obviously it will throw |
It will not throw If a caller called this method without fetching 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 |
I get your point. To be honest, I had same conversation in some other repos with their maintainer. And yes, you are right. calling 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.