chore: mypy for template music provider (#1871)
authorJc2k <john.carr@unrouted.co.uk>
Tue, 14 Jan 2025 16:19:59 +0000 (16:19 +0000)
committerGitHub <noreply@github.com>
Tue, 14 Jan 2025 16:19:59 +0000 (17:19 +0100)
music_assistant/providers/_template_music_provider/__init__.py
pyproject.toml

index 7eaba12ac3e42b2de929eb8bc732614b13bc239e..4ca9064737f42cbaaa0f9b7213c18a5191ed8741 100644 (file)
@@ -40,12 +40,7 @@ from __future__ import annotations
 from collections.abc import AsyncGenerator, Sequence
 from typing import TYPE_CHECKING
 
-from music_assistant_models.enums import (
-    ContentType,
-    MediaType,
-    ProviderFeature,
-    StreamType,
-)
+from music_assistant_models.enums import ContentType, MediaType, ProviderFeature, StreamType
 from music_assistant_models.media_items import (
     Album,
     Artist,
@@ -63,14 +58,10 @@ from music_assistant_models.streamdetails import StreamDetails
 from music_assistant.models.music_provider import MusicProvider
 
 if TYPE_CHECKING:
-    from music_assistant_models.config_entries import (
-        ConfigEntry,
-        ConfigValueType,
-        ProviderConfig,
-    )
+    from music_assistant_models.config_entries import ConfigEntry, ConfigValueType, ProviderConfig
     from music_assistant_models.provider import ProviderManifest
 
-    from music_assistant import MusicAssistant
+    from music_assistant.mass import MusicAssistant
     from music_assistant.models import ProviderInstanceType
 
 
@@ -142,7 +133,7 @@ class MyDemoMusicprovider(MusicProvider):
         # you should return a tuple of provider-level features
         # here that your player provider supports or an empty tuple if none.
         # for example 'ProviderFeature.SYNC_PLAYERS' if you can sync players.
-        return (
+        return {
             ProviderFeature.BROWSE,
             ProviderFeature.SEARCH,
             ProviderFeature.RECOMMENDATIONS,
@@ -158,7 +149,7 @@ class MyDemoMusicprovider(MusicProvider):
             ProviderFeature.LIBRARY_PLAYLISTS_EDIT,
             ProviderFeature.SIMILAR_TRACKS,
             # see the ProviderFeature enum for all available features
-        )
+        }
 
     async def loaded_in_mass(self) -> None:
         """Call after the provider has been loaded."""
@@ -196,7 +187,7 @@ class MyDemoMusicprovider(MusicProvider):
         # For streaming providers return True here but for local file based providers return False.
         return True
 
-    async def search(
+    async def search(  # type: ignore[empty-body]
         self,
         search_query: str,
         media_types: list[MediaType],
@@ -256,7 +247,7 @@ class MyDemoMusicprovider(MusicProvider):
         # It allows retrieving the library/favorite albums from your provider.
         # Warning: Async generator:
         # You should yield Album objects for each album in the library.
-        yield  # type: ignore
+        yield  # type: ignore[misc]
 
     async def get_library_tracks(self) -> AsyncGenerator[Track, None]:
         """Retrieve library tracks from the provider."""
@@ -266,7 +257,7 @@ class MyDemoMusicprovider(MusicProvider):
         # It allows retrieving the library/favorite tracks from your provider.
         # Warning: Async generator:
         # You should yield Track objects for each track in the library.
-        yield  # type: ignore
+        yield  # type: ignore[misc]
 
     async def get_library_playlists(self) -> AsyncGenerator[Playlist, None]:
         """Retrieve library/subscribed playlists from the provider."""
@@ -276,7 +267,7 @@ class MyDemoMusicprovider(MusicProvider):
         # It allows retrieving the library/favorite playlists from your provider.
         # Warning: Async generator:
         # You should yield Playlist objects for each playlist in the library.
-        yield  # type: ignore
+        yield  # type: ignore[misc]
 
     async def get_library_radios(self) -> AsyncGenerator[Radio, None]:
         """Retrieve library/subscribed radio stations from the provider."""
@@ -286,53 +277,53 @@ class MyDemoMusicprovider(MusicProvider):
         # It allows retrieving the library/favorite radio stations from your provider.
         # Warning: Async generator:
         # You should yield Radio objects for each radio station in the library.
-        yield
+        yield  # type: ignore[misc]
 
-    async def get_artist(self, prov_artist_id: str) -> Artist:
+    async def get_artist(self, prov_artist_id: str) -> Artist:  # type: ignore[empty-body]
         """Get full artist details by id."""
         # Get full details of a single Artist.
         # Mandatory only if you reported LIBRARY_ARTISTS in the supported_features.
 
-    async def get_artist_albums(self, prov_artist_id: str) -> list[Album]:
+    async def get_artist_albums(self, prov_artist_id: str) -> list[Album]:  # type: ignore[empty-body]
         """Get a list of all albums for the given artist."""
         # Get a list of all albums for the given artist.
         # Mandatory only if you reported ARTIST_ALBUMS in the supported_features.
 
-    async def get_artist_toptracks(self, prov_artist_id: str) -> list[Track]:
+    async def get_artist_toptracks(self, prov_artist_id: str) -> list[Track]:  # type: ignore[empty-body]
         """Get a list of most popular tracks for the given artist."""
         # Get a list of most popular tracks for the given artist.
         # Mandatory only if you reported ARTIST_TOPTRACKS in the supported_features.
         # Note that (local) file based providers will simply return all artist tracks here.
 
-    async def get_album(self, prov_album_id: str) -> Album:  # type: ignore[return]
+    async def get_album(self, prov_album_id: str) -> Album:  # type: ignore[empty-body]
         """Get full album details by id."""
         # Get full details of a single Album.
         # Mandatory only if you reported LIBRARY_ALBUMS in the supported_features.
 
-    async def get_track(self, prov_track_id: str) -> Track:  # type: ignore[return]
+    async def get_track(self, prov_track_id: str) -> Track:  # type: ignore[empty-body]
         """Get full track details by id."""
         # Get full details of a single Track.
         # Mandatory only if you reported LIBRARY_TRACKS in the supported_features.
 
-    async def get_playlist(self, prov_playlist_id: str) -> Playlist:  # type: ignore[return]
+    async def get_playlist(self, prov_playlist_id: str) -> Playlist:  # type: ignore[empty-body]
         """Get full playlist details by id."""
         # Get full details of a single Playlist.
         # Mandatory only if you reported LIBRARY_PLAYLISTS in the supported
 
-    async def get_radio(self, prov_radio_id: str) -> Radio:  # type: ignore[return]
+    async def get_radio(self, prov_radio_id: str) -> Radio:  # type: ignore[empty-body]
         """Get full radio details by id."""
         # Get full details of a single Radio station.
         # Mandatory only if you reported LIBRARY_RADIOS in the supported_features.
 
-    async def get_album_tracks(
+    async def get_album_tracks(  # type: ignore[empty-body]
         self,
-        prov_album_id: str,  # type: ignore[return]
+        prov_album_id: str,
     ) -> list[Track]:
         """Get album tracks for given album id."""
         # Get all tracks for a given album.
         # Mandatory only if you reported ARTIST_ALBUMS in the supported_features.
 
-    async def get_playlist_tracks(
+    async def get_playlist_tracks(  # type: ignore[empty-body]
         self,
         prov_playlist_id: str,
         page: int = 0,
@@ -365,12 +356,12 @@ class MyDemoMusicprovider(MusicProvider):
         # Remove track(s) from a playlist.
         # This is only called if the provider supports the EDPLAYLIST_TRACKS_EDITIT feature.
 
-    async def create_playlist(self, name: str) -> Playlist:  # type: ignore[return]
+    async def create_playlist(self, name: str) -> Playlist:  # type: ignore[empty-body]
         """Create a new playlist on provider with given name."""
         # Create a new playlist on the provider.
         # This is only called if the provider supports the PLAYLIST_CREATE feature.
 
-    async def get_similar_tracks(  # type: ignore[return]
+    async def get_similar_tracks(  # type: ignore[empty-body]
         self, prov_track_id: str, limit: int = 25
     ) -> list[Track]:
         """Retrieve a dynamic list of similar tracks based on the provided track."""
@@ -405,7 +396,7 @@ class MyDemoMusicprovider(MusicProvider):
             # but the above should be the mandatory fields to set.
         )
 
-    async def get_audio_stream(  # type: ignore[return]
+    async def get_audio_stream(
         self, streamdetails: StreamDetails, seek_position: int = 0
     ) -> AsyncGenerator[bytes, None]:
         """
@@ -417,7 +408,7 @@ class MyDemoMusicprovider(MusicProvider):
         # for the given streamdetails. You can use this to provide a custom
         # stream generator for the audio stream. This is only called when the
         # stream_type is set to CUSTOM in the get_stream_details method.
-        yield  # type: ignore
+        yield  # type: ignore[misc]
 
     async def on_streamed(
         self,
index 05ab128273199a9571da57a7e0edc81d7275f924..c7ce2b3f16a6495f5872e7780306b2b9fa430dac 100644 (file)
@@ -122,7 +122,6 @@ exclude = [
   '^music_assistant/controllers/.*$',
   '^music_assistant/helpers/.*$',
   '^music_assistant/models/.*$',
-  '^music_assistant/providers/_template_music_provider/.*$',
   '^music_assistant/providers/_template_player_provider/.*$',
   '^music_assistant/providers/apple_music/.*$',
   '^music_assistant/providers/bluesound/.*$',