mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Fix model import in Spotify (#119747)
* Always import HomeAssistantSpotifyData in spotify.media_browser Relocate HomeAssistantSpotifyData to avoid circular import * Fix moved import * Rename module to 'models' * Adjust docstring
This commit is contained in:
parent
9065042960
commit
59ade9cf93
@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
@ -22,6 +21,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||
|
||||
from .browse_media import async_browse_media
|
||||
from .const import DOMAIN, LOGGER, SPOTIFY_SCOPES
|
||||
from .models import HomeAssistantSpotifyData
|
||||
from .util import (
|
||||
is_spotify_media_type,
|
||||
resolve_spotify_media_type,
|
||||
@ -39,16 +39,6 @@ __all__ = [
|
||||
]
|
||||
|
||||
|
||||
@dataclass
|
||||
class HomeAssistantSpotifyData:
|
||||
"""Spotify data stored in the Home Assistant data object."""
|
||||
|
||||
client: Spotify
|
||||
current_user: dict[str, Any]
|
||||
devices: DataUpdateCoordinator[list[dict[str, Any]]]
|
||||
session: OAuth2Session
|
||||
|
||||
|
||||
type SpotifyConfigEntry = ConfigEntry[HomeAssistantSpotifyData]
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from enum import StrEnum
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import Any
|
||||
|
||||
from spotipy import Spotify
|
||||
import yarl
|
||||
@ -20,11 +20,9 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
|
||||
|
||||
from .const import DOMAIN, MEDIA_PLAYER_PREFIX, MEDIA_TYPE_SHOW, PLAYABLE_MEDIA_TYPES
|
||||
from .models import HomeAssistantSpotifyData
|
||||
from .util import fetch_image_url
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import HomeAssistantSpotifyData
|
||||
|
||||
BROWSE_LIMIT = 48
|
||||
|
||||
|
||||
|
@ -29,9 +29,10 @@ from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from . import HomeAssistantSpotifyData, SpotifyConfigEntry
|
||||
from . import SpotifyConfigEntry
|
||||
from .browse_media import async_browse_media_internal
|
||||
from .const import DOMAIN, MEDIA_PLAYER_PREFIX, PLAYABLE_MEDIA_TYPES, SPOTIFY_SCOPES
|
||||
from .models import HomeAssistantSpotifyData
|
||||
from .util import fetch_image_url
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
19
homeassistant/components/spotify/models.py
Normal file
19
homeassistant/components/spotify/models.py
Normal file
@ -0,0 +1,19 @@
|
||||
"""Models for use in Spotify integration."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from spotipy import Spotify
|
||||
|
||||
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
|
||||
@dataclass
|
||||
class HomeAssistantSpotifyData:
|
||||
"""Spotify data stored in the Home Assistant data object."""
|
||||
|
||||
client: Spotify
|
||||
current_user: dict[str, Any]
|
||||
devices: DataUpdateCoordinator[list[dict[str, Any]]]
|
||||
session: OAuth2Session
|
Loading…
x
Reference in New Issue
Block a user