sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.59k stars 182 forks source link

Fixing function "limit" argument typing #565

Closed allemand-instable closed 3 months ago

allemand-instable commented 3 months ago

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 ;)

sigma67 commented 3 months ago

PR welcome