Closed arusahni closed 1 year ago
Thanks, I will try to test this asap, as I just added a few features to mopidy-tidal that requires Page objects.
Hmm. Thanks for this.
I think you've exposed a real weakness in the class hierarchy here. I've not had a massive amount of thought about it, but instinctively I'd prefer making the spec of all the response types the same (even with a no-op .items()), preferably by making them inherit and implement an ABC. For the time being @arusahni could you do it the other way, i.e. change the class?
As a more general point I'd like to have a shot at thinning out the codebase a bit. The api as it stands is quite fragmented, something which lead to some curious mocking tricks when I first wrote the test suite for mopidy-tidal. Getting typing (and testing) working is a good way to avoid nasty surprises, but I'm personally up for changing our api (with careful consideration) to get rid of some of these inconsistencies. As a step in that direction I think it would be good if PRs started proposing api improvements, i.e. don't feel afraid @arusahni to suggest changes.
At some point we need to rewrite the config class at least a bit.
I don't have massive amounts of time before Christmas, but I might manage to get some work done on things in december. If anyone's browsing by and want to have a shot at refactoring, go for it.
@2e0byo thanks for the review! I sprinkled a bunch of reveal_types
for every item in a chained call and found two core issues that broke mypy's inference (pyright was fine):
Session
playlist
module.I've updated this PR to include typings for playlist
, and fixed #1. There are now far fewer casts.
@arusahni I did some quick tests in Mopidy-Tidal. It looks like everything is working as expected when browsing various pages so at least it looks like these changes didn't break anything.
Thanks @arusahni yet again for the work. I'll run the test suite at some point and then merge this in.
Any more comments on this PR @2e0byo? Otherwise lets merge it in and prepare for next tidalapi release.
@tehkillerbee if the tests pass all is good. Would you check? Thanks for picking this up.
LGTM, will fix remaining review suggestions in a separate PR
This was the hairiest of the type conversions so far. It was complicated by the fact that the
Artist
class does not have an items collection. As a result, thePage
iterator interface would end up raising anAttributeError
if iteration was attempted. Rather than add a no-opitems
method to the theArtist
type, I opted to shim it at thePage
level to keep the API clean.Please nitpick this! While I use the API, I've never used this module.
Advances #137