From: OzGav Date: Fri, 3 Oct 2025 12:33:12 +0000 (+1000) Subject: mypy fixes for DLNA (#2451) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=ba1397aa72deb50a48173b8f4a7fac87b4444776;p=music-assistant-server.git mypy fixes for DLNA (#2451) --- diff --git a/music_assistant/providers/dlna/helpers.py b/music_assistant/providers/dlna/helpers.py index 32242ae8..4f4971b9 100644 --- a/music_assistant/providers/dlna/helpers.py +++ b/music_assistant/providers/dlna/helpers.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: from music_assistant import MusicAssistant -class DLNANotifyServer(UpnpNotifyServer): +class DLNANotifyServer(UpnpNotifyServer): # type: ignore[misc] """Notify server for async_upnp_client which uses the MA webserver.""" def __init__( @@ -35,7 +35,7 @@ class DLNANotifyServer(UpnpNotifyServer): # transform aiohttp request to async_upnp_client request http_request = HttpRequest( method=request.method, - url=request.url, + url=str(request.url), headers=request.headers, body=await request.text(), ) diff --git a/music_assistant/providers/dlna/player.py b/music_assistant/providers/dlna/player.py index 7841b376..1fcf2c7a 100644 --- a/music_assistant/providers/dlna/player.py +++ b/music_assistant/providers/dlna/player.py @@ -128,14 +128,13 @@ class DLNAPlayer(Player): def _handle_event( self, service: UpnpService, - state_variables: Sequence[UpnpStateVariable], + state_variables: Sequence[UpnpStateVariable[Any]], ) -> None: """Handle state variable(s) changed event from DLNA device.""" if not state_variables: # Indicates a failure to resubscribe, check if device is still available self.force_poll = True return - if service.service_id == "urn:upnp-org:serviceId:AVTransport": for state_variable in state_variables: # Force a state refresh when player begins or pauses playback @@ -151,7 +150,6 @@ class DLNAPlayer(Player): self.display_name, state_variable.value, ) - self.last_seen = time.time() self.mass.create_task(self._update_player()) diff --git a/music_assistant/providers/dlna/provider.py b/music_assistant/providers/dlna/provider.py index 98c76249..a4de1b76 100644 --- a/music_assistant/providers/dlna/provider.py +++ b/music_assistant/providers/dlna/provider.py @@ -50,8 +50,7 @@ class DLNAPlayerProvider(PlayerProvider): Called when provider is deregistered (e.g. MA exiting or config reloading). """ self.mass.streams.unregister_dynamic_route("/notify", "NOTIFY") - if self.dlnaplayers is None: - return + async with TaskManager(self.mass) as tg: for dlna_player in self.dlnaplayers.values(): tg.create_task(self._device_disconnect(dlna_player)) diff --git a/pyproject.toml b/pyproject.toml index d916250a..3b98b909 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -144,7 +144,6 @@ exclude = [ '^music_assistant/providers/apple_music/.*$', '^music_assistant/providers/bluesound/.*$', '^music_assistant/providers/chromecast/.*$', - '^music_assistant/providers/dlna/.*$', '^music_assistant/providers/hass_players/.*$', '^music_assistant/providers/player_group/.*$', '^music_assistant/providers/qobuz/.*$',