chore: add mypy for hass (#1891)
authorJc2k <john.carr@unrouted.co.uk>
Mon, 20 Jan 2025 20:49:22 +0000 (20:49 +0000)
committerGitHub <noreply@github.com>
Mon, 20 Jan 2025 20:49:22 +0000 (21:49 +0100)
music_assistant/providers/hass/__init__.py
pyproject.toml

index 0d6203652a85d04554e3c8a906fed7ab8c9a80b0..34ed0c6f1f29737f0e1c34e50cd2a832b4f0963a 100644 (file)
@@ -35,7 +35,7 @@ if TYPE_CHECKING:
     from music_assistant_models.config_entries import 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
 
 DOMAIN = "hass"
@@ -66,9 +66,9 @@ async def get_config_entries(
     values: the (intermediate) raw values for config entries sent with the action.
     """
     # config flow auth action/step (authenticate button clicked)
-    if action == CONF_ACTION_AUTH:
+    if action == CONF_ACTION_AUTH and values:
         hass_url = values[CONF_URL]
-        async with AuthenticationHelper(mass, values["session_id"]) as auth_helper:
+        async with AuthenticationHelper(mass, str(values["session_id"])) as auth_helper:
             client_id = base_url(auth_helper.callback_url)
             auth_url = get_auth_url(
                 hass_url,
@@ -170,7 +170,7 @@ class HomeAssistant(PluginProvider):
     """Home Assistant Plugin for Music Assistant."""
 
     hass: HomeAssistantClient
-    _listen_task: asyncio.Task | None = None
+    _listen_task: asyncio.Task[None] | None = None
 
     async def handle_async_init(self) -> None:
         """Handle async initialization of the plugin."""
index 998ef08d6c60f9ca4d4dd4e5c702efb7b82be1d3..510cccab9ef45ab15cb49fba69baae4ad194303b 100644 (file)
@@ -127,7 +127,6 @@ exclude = [
   '^music_assistant/providers/chromecast/.*$',
   '^music_assistant/providers/deezer/.*$',
   '^music_assistant/providers/dlna/.*$',
-  '^music_assistant/providers/hass/.*$',
   '^music_assistant/providers/hass_players/.*$',
   '^music_assistant/providers/player_group/.*$',
   '^music_assistant/providers/podcastfeed/.*$',