diff --git a/music_assistant/server/models/provider.py b/music_assistant/server/models/provider.py index 0d23cda09..3e6358639 100644 --- a/music_assistant/server/models/provider.py +++ b/music_assistant/server/models/provider.py @@ -6,7 +6,6 @@ from typing import TYPE_CHECKING, Any from music_assistant.constants import CONF_LOG_LEVEL, MASS_LOGGER_NAME -from music_assistant.server.helpers.throttle_retry import ThrottlerManager if TYPE_CHECKING: from zeroconf import ServiceStateChange @@ -21,8 +20,6 @@ class Provider: """Base representation of a Provider implementation within Music Assistant.""" - throttler: ThrottlerManager # optional throttler - def __init__( self, mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig ) -> None: diff --git a/music_assistant/server/providers/theaudiodb/__init__.py b/music_assistant/server/providers/theaudiodb/__init__.py index ccde5cb52..61c3d72ca 100644 --- a/music_assistant/server/providers/theaudiodb/__init__.py +++ b/music_assistant/server/providers/theaudiodb/__init__.py @@ -3,7 +3,7 @@ from __future__ import annotations from json import JSONDecodeError -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, cast import aiohttp.client_exceptions from asyncio_throttle import Throttler @@ -19,9 +19,10 @@ MediaItemLink, MediaItemMetadata, Track, + UniqueList, ) from music_assistant.server.controllers.cache import use_cache -from music_assistant.server.helpers.app_vars import app_var # pylint: disable=no-name-in-module +from music_assistant.server.helpers.app_vars import app_var # type: ignore[attr-defined] from music_assistant.server.helpers.compare import compare_strings from music_assistant.server.models.metadata_provider import MetadataProvider @@ -199,7 +200,7 @@ def __parse_artist(self, artist_obj: dict[str, Any]) -> MediaItemMetadata: else: metadata.description = artist_obj.get("strBiographyEN") # images - metadata.images = [] + metadata.images = UniqueList() for key, img_type in IMG_MAPPING.items(): for postfix in ("", "2", "3", "4", "5", "6", "7", "8", "9", "10"): if img := artist_obj.get(f"{key}{postfix}"): @@ -245,7 +246,7 @@ def __parse_album(self, album_obj: dict[str, Any]) -> MediaItemMetadata: metadata.description = album_obj.get("strDescriptionEN") metadata.review = album_obj.get("strReview") # images - metadata.images = [] + metadata.images = UniqueList() for key, img_type in IMG_MAPPING.items(): for postfix in ("", "2", "3", "4", "5", "6", "7", "8", "9", "10"): if img := album_obj.get(f"{key}{postfix}"): @@ -279,7 +280,7 @@ def __parse_track(self, track_obj: dict[str, Any]) -> MediaItemMetadata: else: metadata.description = track_obj.get("strDescriptionEN") # images - metadata.images = [] + metadata.images = UniqueList([]) for key, img_type in IMG_MAPPING.items(): for postfix in ("", "2", "3", "4", "5", "6", "7", "8", "9", "10"): if img := track_obj.get(f"{key}{postfix}"): @@ -296,7 +297,7 @@ def __parse_track(self, track_obj: dict[str, Any]) -> MediaItemMetadata: return metadata @use_cache(86400 * 30) - async def _get_data(self, endpoint, **kwargs) -> dict | None: + async def _get_data(self, endpoint: str, **kwargs: Any) -> dict[str, Any] | None: """Get data from api.""" url = f"https://theaudiodb.com/api/v1/json/{app_var(3)}/{endpoint}" async with ( @@ -304,7 +305,7 @@ async def _get_data(self, endpoint, **kwargs) -> dict | None: self.mass.http_session.get(url, params=kwargs, ssl=False) as response, ): try: - result = await response.json() + result = cast(dict[str, Any], await response.json()) except ( aiohttp.client_exceptions.ContentTypeError, JSONDecodeError, diff --git a/mypy.ini b/mypy.ini index 777b60a03..fef884fca 100644 --- a/mypy.ini +++ b/mypy.ini @@ -21,4 +21,4 @@ disallow_untyped_decorators = true disallow_untyped_defs = true warn_return_any = true warn_unreachable = true -packages=tests,music_assistant.client,music_assistant.common,music_assistant.server.providers.builtin,music_assistant.server.providers.filesystem_local,music_assistant.server.providers.filesystem_smb,music_assistant.server.providers.fully_kiosk,music_assistant.server.providers.jellyfin,music_assistant.server.providers.plex,music_assistant.server.providers.radiobrowser,music_assistant.server.providers.test +packages=tests,music_assistant.client,music_assistant.common,music_assistant.server.providers.builtin,music_assistant.server.providers.filesystem_local,music_assistant.server.providers.filesystem_smb,music_assistant.server.providers.fully_kiosk,music_assistant.server.providers.jellyfin,music_assistant.server.providers.plex,music_assistant.server.providers.radiobrowser,music_assistant.server.providers.test,music_assistant.server.providers.theaudiodb