[GH-ISSUE #565] Fixing function "limit" argument typing #396

Closed
opened 2026-02-27 23:00:34 +03:00 by kerem · 1 comment
Owner

Originally created by @code-instable on GitHub (Mar 16, 2024).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/565

according to the method "get_library_playlists"'s documentation :

Retrieves the playlists in the user's library.

        :param limit: Number of playlists to retrieve. `None` retrieves them all.
        :return: List of owned playlists.

however None is not a possible type on that function causing a lot of false error flags in the editors

def get_library_playlists(self, limit: int = 25) -> List[Dict]:

should be :

def get_library_playlists(self, limit: int | None = 25) -> List[Dict]:

same problem with get_playlist

def get_playlist(
        self, playlistId: str, limit: int = 100, related: bool = False, suggestions_limit: int = 0
    ) -> Dict:
        """
        Returns a list of playlist items

        :param playlistId: Playlist id
        :param limit: How many songs to return. `None` retrieves them all. Default: 100
        :param related: Whether to fetch 10 related playlists or not. Default: False
        :param suggestions_limit: How many suggestions to return. The result is a list of
            suggested playlist items (videos) contained in a "suggestions" key.
            7 items are retrieved in each internal request. Default: 0
        :return: Dictionary with information about the playlist.
            The key ``tracks`` contains a List of playlistItem dictionaries

Might also be the case for other methods, fixing it should be easy and improve significantly the experience of using this python library.

Thank you ;)

Originally created by @code-instable on GitHub (Mar 16, 2024). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/565 according to the method "get_library_playlists"'s documentation : ``` Retrieves the playlists in the user's library. :param limit: Number of playlists to retrieve. `None` retrieves them all. :return: List of owned playlists. ``` however None is not a possible type on that function causing a lot of false error flags in the editors ```python def get_library_playlists(self, limit: int = 25) -> List[Dict]: ``` should be : ```python def get_library_playlists(self, limit: int | None = 25) -> List[Dict]: ``` --- same problem with `get_playlist` ```python def get_playlist( self, playlistId: str, limit: int = 100, related: bool = False, suggestions_limit: int = 0 ) -> Dict: """ Returns a list of playlist items :param playlistId: Playlist id :param limit: How many songs to return. `None` retrieves them all. Default: 100 :param related: Whether to fetch 10 related playlists or not. Default: False :param suggestions_limit: How many suggestions to return. The result is a list of suggested playlist items (videos) contained in a "suggestions" key. 7 items are retrieved in each internal request. Default: 0 :return: Dictionary with information about the playlist. The key ``tracks`` contains a List of playlistItem dictionaries ``` --- Might also be the case for other methods, fixing it should be easy and improve significantly the experience of using this python library. Thank you ;)
kerem 2026-02-27 23:00:34 +03:00
Author
Owner

@sigma67 commented on GitHub (Mar 16, 2024):

PR welcome

<!-- gh-comment-id:2002132205 --> @sigma67 commented on GitHub (Mar 16, 2024): PR welcome
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#396
No description provided.