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: don't forward parent when getting artist radio #1211

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/deezer/resources/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def get_radio(self, **kwargs) -> list[Track]:

:returns: list of :class:`Track <deezer.Track>` instances
"""
return self.get_relation("radio", **kwargs)
# radio returns tracks from different artists -> no fwd parent
return self.get_relation("radio", fwd_parent=False, **kwargs)

def get_albums(self, **kwargs) -> PaginatedList[Album]:
"""
Expand Down
3 changes: 2 additions & 1 deletion src/deezer/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_relation(
relation: str,
resource_type: type[Resource] | None = None, # type: ignore[valid-type]
params: dict | None = None,
fwd_parent: bool = True,
):
"""
Generic method to load the relation from any resource.
Expand All @@ -73,7 +74,7 @@ def get_relation(
return self.client.request(
"GET",
f"{self.type}/{self.id}/{relation}",
parent=self,
parent=self if fwd_parent else None,
resource_type=resource_type,
params=params,
)
Expand Down
1 change: 1 addition & 0 deletions tests/resources/test_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_get_radio(self, daft_punk):
track = tracks[0]
assert isinstance(track, deezer.Track)
assert repr(track) == "<Track: One More Time>"
assert any(track_.artist.name != daft_punk.name for track_ in tracks)

def test_get_related(self, daft_punk):
related_artists = daft_punk.get_related()
Expand Down
Loading