Skip to content

Commit

Permalink
client.py docstring updates (#1060)
Browse files Browse the repository at this point in the history
* Update client.py 

Added warnings in docstrings for functions that have been replaced and call other new functions.

* Update CHANGELOG.md

---------

Co-authored-by: Stéphane Bruckert <[email protected]>
  • Loading branch information
bparrott3 and stephanebruckert authored Jun 23, 2024
1 parent c90ce4a commit d764040
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Add your changes below.

### Fixed
- Audiobook integration tests
- Edited docstrings for certain functions in client.py for functions that are no longer in use and have been replaced.

### Removed
- `mock` no longer listed as a test dependency. Only built-in `unittest.mock` is actually used.
Expand Down
83 changes: 50 additions & 33 deletions spotipy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,9 @@ def user_playlist_change_details(
collaborative=None,
description=None,
):
warnings.warn(
"You should use `playlist_change_details(playlist_id, ...)` instead",
DeprecationWarning,
)
""" Changes a playlist's name and/or public/private state
""" This function is no longer in use, please use the recommended function in the warning!
Changes a playlist's name and/or public/private state
Parameters:
- user - the id of the user
Expand All @@ -855,12 +853,18 @@ def user_playlist_change_details(
- collaborative - optional is the playlist collaborative
- description - optional description of the playlist
"""
warnings.warn(
"You should use `playlist_change_details(playlist_id, ...)` instead",
DeprecationWarning,
)

return self.playlist_change_details(playlist_id, name, public,
collaborative, description)

def user_playlist_unfollow(self, user, playlist_id):
""" Unfollows (deletes) a playlist for a user
""" This function is no longer in use, please use the recommended function in the warning!
Unfollows (deletes) a playlist for a user
Parameters:
- user - the id of the user
Expand All @@ -875,41 +879,49 @@ def user_playlist_unfollow(self, user, playlist_id):
def user_playlist_add_tracks(
self, user, playlist_id, tracks, position=None
):
warnings.warn(
"You should use `playlist_add_items(playlist_id, tracks)` instead",
DeprecationWarning,
)
""" Adds tracks to a playlist
""" This function is no longer in use, please use the recommended function in the warning!
Adds tracks to a playlist
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- tracks - a list of track URIs, URLs or IDs
- position - the position to add the tracks
"""
warnings.warn(
"You should use `playlist_add_items(playlist_id, tracks)` instead",
DeprecationWarning,
)

tracks = [self._get_uri("track", tid) for tid in tracks]
return self.playlist_add_items(playlist_id, tracks, position)

def user_playlist_add_episodes(
self, user, playlist_id, episodes, position=None
):
warnings.warn(
"You should use `playlist_add_items(playlist_id, episodes)` instead",
DeprecationWarning,
)
""" Adds episodes to a playlist
""" This function is no longer in use, please use the recommended function in the warning!
Adds episodes to a playlist
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- episodes - a list of track URIs, URLs or IDs
- position - the position to add the episodes
"""
warnings.warn(
"You should use `playlist_add_items(playlist_id, episodes)` instead",
DeprecationWarning,
)

episodes = [self._get_uri("episode", tid) for tid in episodes]
return self.playlist_add_items(playlist_id, episodes, position)

def user_playlist_replace_tracks(self, user, playlist_id, tracks):
""" Replace all tracks in a playlist for a user
""" This function is no longer in use, please use the recommended function in the warning!
Replace all tracks in a playlist for a user
Parameters:
- user - the id of the user
Expand All @@ -931,7 +943,9 @@ def user_playlist_reorder_tracks(
range_length=1,
snapshot_id=None,
):
""" Reorder tracks in a playlist from a user
""" This function is no longer in use, please use the recommended function in the warning!
Reorder tracks in a playlist from a user
Parameters:
- user - the id of the user
Expand All @@ -954,14 +968,15 @@ def user_playlist_reorder_tracks(
def user_playlist_remove_all_occurrences_of_tracks(
self, user, playlist_id, tracks, snapshot_id=None
):
""" Removes all occurrences of the given tracks from the given playlist
""" This function is no longer in use, please use the recommended function in the warning!
Removes all occurrences of the given tracks from the given playlist
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- tracks - the list of track ids to remove from the playlist
- snapshot_id - optional id of the playlist snapshot
"""
warnings.warn(
"You should use `playlist_remove_all_occurrences_of_items"
Expand All @@ -975,7 +990,9 @@ def user_playlist_remove_all_occurrences_of_tracks(
def user_playlist_remove_specific_occurrences_of_tracks(
self, user, playlist_id, tracks, snapshot_id=None
):
""" Removes all occurrences of the given tracks from the given playlist
""" This function is no longer in use, please use the recommended function in the warning!
Removes all occurrences of the given tracks from the given playlist
Parameters:
- user - the id of the user
Expand Down Expand Up @@ -1009,13 +1026,13 @@ def user_playlist_remove_specific_occurrences_of_tracks(
)

def user_playlist_follow_playlist(self, playlist_owner_id, playlist_id):
"""
Add the current authenticated user as a follower of a playlist.
""" This function is no longer in use, please use the recommended function in the warning!
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
Add the current authenticated user as a follower of a playlist.
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
"""
warnings.warn(
"You should use `current_user_follow_playlist(playlist_id)` instead",
Expand All @@ -1026,15 +1043,15 @@ def user_playlist_follow_playlist(self, playlist_owner_id, playlist_id):
def user_playlist_is_following(
self, playlist_owner_id, playlist_id, user_ids
):
"""
Check to see if the given users are following the given playlist
""" This function is no longer in use, please use the recommended function in the warning!
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
- user_ids - the ids of the users that you want to check to see
if they follow the playlist. Maximum: 5 ids.
Check to see if the given users are following the given playlist
Parameters:
- playlist_owner_id - the user id of the playlist owner
- playlist_id - the id of the playlist
- user_ids - the ids of the users that you want to check to see
if they follow the playlist. Maximum: 5 ids.
"""
warnings.warn(
"You should use `playlist_is_following(playlist_id, user_ids)` instead",
Expand Down

0 comments on commit d764040

Please sign in to comment.