From cd52e050752e7d4854b2c3ed20deca2cb974bf6a Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sun, 30 Apr 2023 18:09:02 +0200 Subject: [PATCH] Move lastfm constants to separate file (#92289) --- homeassistant/components/lastfm/const.py | 15 +++++++++++++++ homeassistant/components/lastfm/sensor.py | 18 ++++++++---------- tests/components/lastfm/test_sensor.py | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 homeassistant/components/lastfm/const.py diff --git a/homeassistant/components/lastfm/const.py b/homeassistant/components/lastfm/const.py new file mode 100644 index 00000000000..2a7f40b99e3 --- /dev/null +++ b/homeassistant/components/lastfm/const.py @@ -0,0 +1,15 @@ +"""Constants for LastFM.""" +import logging +from typing import Final + +LOGGER = logging.getLogger(__package__) +DOMAIN: Final = "lastfm" +DEFAULT_NAME = "LastFM" + +CONF_USERS = "users" + +ATTR_LAST_PLAYED = "last_played" +ATTR_PLAY_COUNT = "play_count" +ATTR_TOP_PLAYED = "top_played" + +STATE_NOT_SCROBBLING = "Not Scrobbling" diff --git a/homeassistant/components/lastfm/sensor.py b/homeassistant/components/lastfm/sensor.py index a25171f9c2e..20c51f8a8c6 100644 --- a/homeassistant/components/lastfm/sensor.py +++ b/homeassistant/components/lastfm/sensor.py @@ -2,7 +2,6 @@ from __future__ import annotations import hashlib -import logging from pylast import LastFMNetwork, Track, User, WSError import voluptuous as vol @@ -14,15 +13,14 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -LOGGER = logging.getLogger(__name__) - -CONF_USERS = "users" - -ATTR_LAST_PLAYED = "last_played" -ATTR_PLAY_COUNT = "play_count" -ATTR_TOP_PLAYED = "top_played" - -STATE_NOT_SCROBBLING = "Not Scrobbling" +from .const import ( + ATTR_LAST_PLAYED, + ATTR_PLAY_COUNT, + ATTR_TOP_PLAYED, + CONF_USERS, + LOGGER, + STATE_NOT_SCROBBLING, +) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { diff --git a/tests/components/lastfm/test_sensor.py b/tests/components/lastfm/test_sensor.py index 0fa45a12277..d9de78b8f8a 100644 --- a/tests/components/lastfm/test_sensor.py +++ b/tests/components/lastfm/test_sensor.py @@ -5,7 +5,7 @@ from pylast import Track import pytest from homeassistant.components import sensor -from homeassistant.components.lastfm.sensor import STATE_NOT_SCROBBLING +from homeassistant.components.lastfm.const import STATE_NOT_SCROBBLING from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component