From 2e084f260e64f8f508d7b0b7f896c8ac97505274 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Thu, 22 Apr 2021 16:21:38 +0200 Subject: [PATCH] =?UTF-8?q?Rename=20HomeAssistantType=20=E2=80=94>=20HomeA?= =?UTF-8?q?ssistant,=20integrations=20s*=20-=20t*=20(#49550)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homeassistant/components/solarlog/__init__.py | 4 +-- homeassistant/components/soma/__init__.py | 6 ++-- homeassistant/components/somfy/__init__.py | 7 ++--- homeassistant/components/sonarr/__init__.py | 8 ++--- .../components/sonarr/config_flow.py | 6 ++-- homeassistant/components/sonarr/sensor.py | 4 +-- homeassistant/components/songpal/__init__.py | 8 ++--- .../components/songpal/media_player.py | 6 ++-- homeassistant/components/stt/__init__.py | 7 ++--- .../components/switcher_kis/__init__.py | 6 ++-- .../components/switcher_kis/switch.py | 5 ++-- homeassistant/components/syncthru/__init__.py | 6 ++-- .../components/synology_dsm/__init__.py | 13 ++++---- .../components/synology_dsm/binary_sensor.py | 4 +-- .../components/synology_dsm/camera.py | 4 +-- .../components/synology_dsm/sensor.py | 4 +-- .../components/synology_dsm/switch.py | 4 +-- .../components/tasmota/device_trigger.py | 4 +-- homeassistant/components/tasmota/discovery.py | 6 ++-- homeassistant/components/timer/__init__.py | 6 ++-- .../components/timer/reproduce_state.py | 7 ++--- .../components/toon/binary_sensor.py | 4 +-- homeassistant/components/toon/climate.py | 4 +-- homeassistant/components/toon/switch.py | 4 +-- tests/components/sonarr/__init__.py | 4 +-- tests/components/sonarr/test_config_flow.py | 16 +++++----- tests/components/sonarr/test_sensor.py | 8 ++--- tests/components/switcher_kis/test_init.py | 15 +++++----- .../synology_dsm/test_config_flow.py | 30 ++++++++----------- tests/components/synology_dsm/test_init.py | 4 +-- 30 files changed, 103 insertions(+), 111 deletions(-) diff --git a/homeassistant/components/solarlog/__init__.py b/homeassistant/components/solarlog/__init__.py index 51aa21eb3151..5db2e15f1216 100644 --- a/homeassistant/components/solarlog/__init__.py +++ b/homeassistant/components/solarlog/__init__.py @@ -1,9 +1,9 @@ """Solar-Log integration.""" from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up a config entry for solarlog.""" hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, "sensor") diff --git a/homeassistant/components/soma/__init__.py b/homeassistant/components/soma/__init__.py index 3f15199c162b..7c4d252208ab 100644 --- a/homeassistant/components/soma/__init__.py +++ b/homeassistant/components/soma/__init__.py @@ -7,9 +7,9 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity -from homeassistant.helpers.typing import HomeAssistantType from .const import API, DOMAIN, HOST, PORT @@ -43,7 +43,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Soma from a config entry.""" hass.data[DOMAIN] = {} hass.data[DOMAIN][API] = SomaApi(entry.data[HOST], entry.data[PORT]) @@ -58,7 +58,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( diff --git a/homeassistant/components/somfy/__init__.py b/homeassistant/components/somfy/__init__.py index 9d67675f10e2..e7a8d7182472 100644 --- a/homeassistant/components/somfy/__init__.py +++ b/homeassistant/components/somfy/__init__.py @@ -10,14 +10,13 @@ import voluptuous as vol from homeassistant.components.somfy import config_flow from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_OPTIMISTIC -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import ( config_entry_oauth2_flow, config_validation as cv, device_registry as dr, ) from homeassistant.helpers.entity import Entity -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -73,7 +72,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Somfy from a config entry.""" # Backwards compat if "auth_implementation" not in entry.data: @@ -142,7 +141,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" hass.data[DOMAIN].pop(API, None) await asyncio.gather( diff --git a/homeassistant/components/sonarr/__init__.py b/homeassistant/components/sonarr/__init__.py index ad5b0299f3eb..12fe47f80c71 100644 --- a/homeassistant/components/sonarr/__init__.py +++ b/homeassistant/components/sonarr/__init__.py @@ -17,10 +17,10 @@ from homeassistant.const import ( CONF_SSL, CONF_VERIFY_SSL, ) +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity import Entity -from homeassistant.helpers.typing import HomeAssistantType from .const import ( ATTR_IDENTIFIERS, @@ -41,7 +41,7 @@ SCAN_INTERVAL = timedelta(seconds=30) _LOGGER = logging.getLogger(__name__) -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Sonarr from a config entry.""" if not entry.options: options = { @@ -89,7 +89,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = all( await asyncio.gather( @@ -108,7 +108,7 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> boo return unload_ok -async def _async_update_listener(hass: HomeAssistantType, entry: ConfigEntry) -> None: +async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None: """Handle options update.""" await hass.config_entries.async_reload(entry.entry_id) diff --git a/homeassistant/components/sonarr/config_flow.py b/homeassistant/components/sonarr/config_flow.py index fe4cdd13454f..acee381591c7 100644 --- a/homeassistant/components/sonarr/config_flow.py +++ b/homeassistant/components/sonarr/config_flow.py @@ -15,9 +15,9 @@ from homeassistant.const import ( CONF_SSL, CONF_VERIFY_SSL, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.aiohttp_client import async_get_clientsession -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from .const import ( CONF_BASE_PATH, @@ -35,7 +35,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -async def validate_input(hass: HomeAssistantType, data: dict) -> dict[str, Any]: +async def validate_input(hass: HomeAssistant, data: dict) -> dict[str, Any]: """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. diff --git a/homeassistant/components/sonarr/sensor.py b/homeassistant/components/sonarr/sensor.py index 3446130433e8..e7ec3e7844c2 100644 --- a/homeassistant/components/sonarr/sensor.py +++ b/homeassistant/components/sonarr/sensor.py @@ -10,8 +10,8 @@ from sonarr import Sonarr, SonarrConnectionError, SonarrError from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DATA_GIGABYTES +from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import Entity -from homeassistant.helpers.typing import HomeAssistantType import homeassistant.util.dt as dt_util from . import SonarrEntity @@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__) async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list[Entity], bool], None], ) -> None: diff --git a/homeassistant/components/songpal/__init__.py b/homeassistant/components/songpal/__init__.py index d6e31fb9a1cf..b5d87e29c453 100644 --- a/homeassistant/components/songpal/__init__.py +++ b/homeassistant/components/songpal/__init__.py @@ -5,8 +5,8 @@ import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import CONF_NAME +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv -from homeassistant.helpers.typing import HomeAssistantType from .const import CONF_ENDPOINT, DOMAIN @@ -20,7 +20,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass: HomeAssistantType, config: OrderedDict) -> bool: +async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool: """Set up songpal environment.""" conf = config.get(DOMAIN) if conf is None: @@ -36,7 +36,7 @@ async def async_setup(hass: HomeAssistantType, config: OrderedDict) -> bool: return True -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up songpal media player.""" hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, "media_player") @@ -44,6 +44,6 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload songpal media player.""" return await hass.config_entries.async_forward_entry_unload(entry, "media_player") diff --git a/homeassistant/components/songpal/media_player.py b/homeassistant/components/songpal/media_player.py index 2a0bde306b7f..5cc1f9b542a6 100644 --- a/homeassistant/components/songpal/media_player.py +++ b/homeassistant/components/songpal/media_player.py @@ -25,13 +25,13 @@ from homeassistant.components.media_player.const import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP, STATE_OFF, STATE_ON +from homeassistant.core import HomeAssistant from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers import ( config_validation as cv, device_registry as dr, entity_platform, ) -from homeassistant.helpers.typing import HomeAssistantType from .const import CONF_ENDPOINT, DOMAIN, SET_SOUND_SETTING @@ -53,7 +53,7 @@ INITIAL_RETRY_DELAY = 10 async def async_setup_platform( - hass: HomeAssistantType, config: dict, async_add_entities, discovery_info=None + hass: HomeAssistant, config: dict, async_add_entities, discovery_info=None ) -> None: """Set up from legacy configuration file. Obsolete.""" _LOGGER.error( @@ -62,7 +62,7 @@ async def async_setup_platform( async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up songpal media player.""" name = config_entry.data[CONF_NAME] diff --git a/homeassistant/components/stt/__init__.py b/homeassistant/components/stt/__init__.py index 5c45e5e3d445..694ddeff9987 100644 --- a/homeassistant/components/stt/__init__.py +++ b/homeassistant/components/stt/__init__.py @@ -15,9 +15,8 @@ from aiohttp.web_exceptions import ( import attr from homeassistant.components.http import HomeAssistantView -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_per_platform, discovery -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.setup import async_prepare_setup_platform from .const import ( @@ -35,7 +34,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -async def async_setup(hass: HomeAssistantType, config): +async def async_setup(hass: HomeAssistant, config): """Set up STT.""" providers = {} @@ -104,7 +103,7 @@ class SpeechResult: class Provider(ABC): """Represent a single STT provider.""" - hass: HomeAssistantType | None = None + hass: HomeAssistant | None = None name: str | None = None @property diff --git a/homeassistant/components/switcher_kis/__init__.py b/homeassistant/components/switcher_kis/__init__.py index 8d39182dcc32..5483ad88c2d9 100644 --- a/homeassistant/components/switcher_kis/__init__.py +++ b/homeassistant/components/switcher_kis/__init__.py @@ -10,12 +10,12 @@ import voluptuous as vol from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.const import CONF_DEVICE_ID, EVENT_HOMEASSISTANT_STOP -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval -from homeassistant.helpers.typing import EventType, HomeAssistantType +from homeassistant.helpers.typing import EventType _LOGGER = logging.getLogger(__name__) @@ -46,7 +46,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass: HomeAssistantType, config: dict) -> bool: +async def async_setup(hass: HomeAssistant, config: dict) -> bool: """Set up the switcher component.""" phone_id = config[DOMAIN][CONF_PHONE_ID] device_id = config[DOMAIN][CONF_DEVICE_ID] diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index 61297142716c..5bad50a79859 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -16,9 +16,10 @@ from aioswitcher.devices import SwitcherV2Device import voluptuous as vol from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchEntity +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.typing import HomeAssistantType, ServiceCallType +from homeassistant.helpers.typing import ServiceCallType from . import ( ATTR_AUTO_OFF_SET, @@ -53,7 +54,7 @@ SERVICE_TURN_ON_WITH_TIMER_SCHEMA = { async def async_setup_platform( - hass: HomeAssistantType, + hass: HomeAssistant, config: dict, async_add_entities: Callable, discovery_info: dict, diff --git a/homeassistant/components/syncthru/__init__.py b/homeassistant/components/syncthru/__init__.py index 888dd22c0908..b09f799df366 100644 --- a/homeassistant/components/syncthru/__init__.py +++ b/homeassistant/components/syncthru/__init__.py @@ -8,16 +8,16 @@ from pysyncthru import SyncThru from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_URL +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import aiohttp_client, device_registry as dr -from homeassistant.helpers.typing import HomeAssistantType from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up config entry.""" session = aiohttp_client.async_get_clientsession(hass) @@ -53,7 +53,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload the config entry.""" await hass.config_entries.async_forward_entry_unload(entry, SENSOR_DOMAIN) hass.data[DOMAIN].pop(entry.entry_id, None) diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index 16b531b9ee3d..3c9461f6ca3e 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -36,11 +36,10 @@ from homeassistant.const import ( CONF_USERNAME, CONF_VERIFY_SSL, ) -from homeassistant.core import ServiceCall, callback +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import entity_registry import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -119,7 +118,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Synology DSM sensors.""" # Migrate old unique_id @@ -294,7 +293,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload Synology DSM sensors.""" unload_ok = all( await asyncio.gather( @@ -314,12 +313,12 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): return unload_ok -async def _async_update_listener(hass: HomeAssistantType, entry: ConfigEntry): +async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry): """Handle options update.""" await hass.config_entries.async_reload(entry.entry_id) -async def _async_setup_services(hass: HomeAssistantType): +async def _async_setup_services(hass: HomeAssistant): """Service handler setup.""" async def service_handler(call: ServiceCall): @@ -358,7 +357,7 @@ async def _async_setup_services(hass: HomeAssistantType): class SynoApi: """Class to interface with Synology DSM API.""" - def __init__(self, hass: HomeAssistantType, entry: ConfigEntry): + def __init__(self, hass: HomeAssistant, entry: ConfigEntry): """Initialize the API wrapper class.""" self._hass = hass self._entry = entry diff --git a/homeassistant/components/synology_dsm/binary_sensor.py b/homeassistant/components/synology_dsm/binary_sensor.py index fb8ed5a23cdb..587f89cf16a6 100644 --- a/homeassistant/components/synology_dsm/binary_sensor.py +++ b/homeassistant/components/synology_dsm/binary_sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_DISKS -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from . import SynologyDSMBaseEntity, SynologyDSMDeviceEntity from .const import ( @@ -18,7 +18,7 @@ from .const import ( async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up the Synology NAS binary sensor.""" diff --git a/homeassistant/components/synology_dsm/camera.py b/homeassistant/components/synology_dsm/camera.py index 67052543569e..cdd4b88186a9 100644 --- a/homeassistant/components/synology_dsm/camera.py +++ b/homeassistant/components/synology_dsm/camera.py @@ -11,7 +11,7 @@ from synology_dsm.exceptions import ( from homeassistant.components.camera import SUPPORT_STREAM, Camera from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import SynoApi, SynologyDSMBaseEntity @@ -30,7 +30,7 @@ _LOGGER = logging.getLogger(__name__) async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up the Synology NAS cameras.""" diff --git a/homeassistant/components/synology_dsm/sensor.py b/homeassistant/components/synology_dsm/sensor.py index 22f41601e7ba..d4a9b0bb7fc7 100644 --- a/homeassistant/components/synology_dsm/sensor.py +++ b/homeassistant/components/synology_dsm/sensor.py @@ -13,8 +13,8 @@ from homeassistant.const import ( PRECISION_TENTHS, TEMP_CELSIUS, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers.temperature import display_temp -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.util.dt import utcnow @@ -34,7 +34,7 @@ from .const import ( async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up the Synology NAS Sensor.""" diff --git a/homeassistant/components/synology_dsm/switch.py b/homeassistant/components/synology_dsm/switch.py index f9883b0c9162..3b71e481d6e4 100644 --- a/homeassistant/components/synology_dsm/switch.py +++ b/homeassistant/components/synology_dsm/switch.py @@ -7,7 +7,7 @@ from synology_dsm.api.surveillance_station import SynoSurveillanceStation from homeassistant.components.switch import ToggleEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import SynoApi, SynologyDSMBaseEntity @@ -17,7 +17,7 @@ _LOGGER = logging.getLogger(__name__) async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up the Synology NAS switch.""" diff --git a/homeassistant/components/tasmota/device_trigger.py b/homeassistant/components/tasmota/device_trigger.py index ae4a528efc66..d4aca9b07caa 100644 --- a/homeassistant/components/tasmota/device_trigger.py +++ b/homeassistant/components/tasmota/device_trigger.py @@ -17,7 +17,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, TASMOTA_EVENT from .discovery import TASMOTA_DISCOVERY_ENTITY_UPDATED, clear_discovery_hash @@ -82,7 +82,7 @@ class Trigger: device_id: str = attr.ib() discovery_hash: dict = attr.ib() - hass: HomeAssistantType = attr.ib() + hass: HomeAssistant = attr.ib() remove_update_signal: Callable[[], None] = attr.ib() subtype: str = attr.ib() tasmota_trigger: TasmotaTrigger = attr.ib() diff --git a/homeassistant/components/tasmota/discovery.py b/homeassistant/components/tasmota/discovery.py index 22824e9cd716..600b2fd293e4 100644 --- a/homeassistant/components/tasmota/discovery.py +++ b/homeassistant/components/tasmota/discovery.py @@ -12,9 +12,9 @@ from hatasmota.discovery import ( ) import homeassistant.components.sensor as sensor +from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.entity_registry import async_entries_for_device -from homeassistant.helpers.typing import HomeAssistantType from .const import DOMAIN, PLATFORMS @@ -40,7 +40,7 @@ def set_discovery_hash(hass, discovery_hash): async def async_start( - hass: HomeAssistantType, discovery_topic, config_entry, tasmota_mqtt, setup_device + hass: HomeAssistant, discovery_topic, config_entry, tasmota_mqtt, setup_device ) -> bool: """Start Tasmota device discovery.""" @@ -168,7 +168,7 @@ async def async_start( hass.data[TASMOTA_DISCOVERY_INSTANCE] = tasmota_discovery -async def async_stop(hass: HomeAssistantType) -> bool: +async def async_stop(hass: HomeAssistant) -> bool: """Stop Tasmota device discovery.""" hass.data.pop(ALREADY_DISCOVERED) tasmota_discovery = hass.data.pop(TASMOTA_DISCOVERY_INSTANCE) diff --git a/homeassistant/components/timer/__init__.py b/homeassistant/components/timer/__init__.py index 2ff408dcd819..9a2b053a8e3d 100644 --- a/homeassistant/components/timer/__init__.py +++ b/homeassistant/components/timer/__init__.py @@ -13,7 +13,7 @@ from homeassistant.const import ( CONF_NAME, SERVICE_RELOAD, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import collection import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_component import EntityComponent @@ -21,7 +21,7 @@ from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.restore_state import RestoreEntity import homeassistant.helpers.service from homeassistant.helpers.storage import Store -from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType +from homeassistant.helpers.typing import ConfigType, ServiceCallType import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -100,7 +100,7 @@ CONFIG_SCHEMA = vol.Schema( RELOAD_SERVICE_SCHEMA = vol.Schema({}) -async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up an input select.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() diff --git a/homeassistant/components/timer/reproduce_state.py b/homeassistant/components/timer/reproduce_state.py index 3ab7d4815cf3..33aed933a063 100644 --- a/homeassistant/components/timer/reproduce_state.py +++ b/homeassistant/components/timer/reproduce_state.py @@ -7,8 +7,7 @@ import logging from typing import Any from homeassistant.const import ATTR_ENTITY_ID -from homeassistant.core import Context, State -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import Context, HomeAssistant, State from . import ( ATTR_DURATION, @@ -27,7 +26,7 @@ VALID_STATES = {STATUS_IDLE, STATUS_ACTIVE, STATUS_PAUSED} async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -69,7 +68,7 @@ async def _async_reproduce_state( async def async_reproduce_states( - hass: HomeAssistantType, + hass: HomeAssistant, states: Iterable[State], *, context: Context | None = None, diff --git a/homeassistant/components/toon/binary_sensor.py b/homeassistant/components/toon/binary_sensor.py index 6651806a21c7..4a55911dcfc5 100644 --- a/homeassistant/components/toon/binary_sensor.py +++ b/homeassistant/components/toon/binary_sensor.py @@ -3,7 +3,7 @@ from __future__ import annotations from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import ( ATTR_DEFAULT_ENABLED, @@ -26,7 +26,7 @@ from .models import ( async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up a Toon binary sensor based on a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] diff --git a/homeassistant/components/toon/climate.py b/homeassistant/components/toon/climate.py index db2bed47f516..1c7bde7d9e5c 100644 --- a/homeassistant/components/toon/climate.py +++ b/homeassistant/components/toon/climate.py @@ -24,7 +24,7 @@ from homeassistant.components.climate.const import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN from .helpers import toon_exception_handler @@ -32,7 +32,7 @@ from .models import ToonDisplayDeviceEntity async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up a Toon binary sensors based on a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] diff --git a/homeassistant/components/toon/switch.py b/homeassistant/components/toon/switch.py index d529dd07075f..b830f53179ef 100644 --- a/homeassistant/components/toon/switch.py +++ b/homeassistant/components/toon/switch.py @@ -10,7 +10,7 @@ from toonapi import ( from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import ( ATTR_DEFAULT_ENABLED, @@ -28,7 +28,7 @@ from .models import ToonDisplayDeviceEntity, ToonEntity async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up a Toon switches based on a config entry.""" coordinator = hass.data[DOMAIN][entry.entry_id] diff --git a/tests/components/sonarr/__init__.py b/tests/components/sonarr/__init__.py index c1d4fc30736f..e3ae6bfa8374 100644 --- a/tests/components/sonarr/__init__.py +++ b/tests/components/sonarr/__init__.py @@ -18,7 +18,7 @@ from homeassistant.const import ( CONF_VERIFY_SSL, CONTENT_TYPE_JSON, ) -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry, load_fixture from tests.test_util.aiohttp import AiohttpClientMocker @@ -176,7 +176,7 @@ def mock_connection_server_error( async def setup_integration( - hass: HomeAssistantType, + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, host: str = HOST, port: str = PORT, diff --git a/tests/components/sonarr/test_config_flow.py b/tests/components/sonarr/test_config_flow.py index 71ec14202440..c1896061f79a 100644 --- a/tests/components/sonarr/test_config_flow.py +++ b/tests/components/sonarr/test_config_flow.py @@ -10,12 +10,12 @@ from homeassistant.components.sonarr.const import ( ) from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_SOURCE, CONF_VERIFY_SSL +from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import ( RESULT_TYPE_ABORT, RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM, ) -from homeassistant.helpers.typing import HomeAssistantType from tests.components.sonarr import ( HOST, @@ -30,7 +30,7 @@ from tests.components.sonarr import ( from tests.test_util.aiohttp import AiohttpClientMocker -async def test_show_user_form(hass: HomeAssistantType) -> None: +async def test_show_user_form(hass: HomeAssistant) -> None: """Test that the user set up form is served.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -42,7 +42,7 @@ async def test_show_user_form(hass: HomeAssistantType) -> None: async def test_cannot_connect( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we show user form on connection error.""" mock_connection_error(aioclient_mock) @@ -60,7 +60,7 @@ async def test_cannot_connect( async def test_invalid_auth( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we show user form on invalid auth.""" mock_connection_invalid_auth(aioclient_mock) @@ -78,7 +78,7 @@ async def test_invalid_auth( async def test_unknown_error( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test we show user form on unknown error.""" user_input = MOCK_USER_INPUT.copy() @@ -97,7 +97,7 @@ async def test_unknown_error( async def test_full_reauth_flow_implementation( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the manual reauth flow from start to finish.""" entry = await setup_integration( @@ -137,7 +137,7 @@ async def test_full_reauth_flow_implementation( async def test_full_user_flow_implementation( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the full manual user flow from start to finish.""" mock_connection(aioclient_mock) @@ -166,7 +166,7 @@ async def test_full_user_flow_implementation( async def test_full_user_flow_advanced_options( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the full manual user flow with advanced options.""" mock_connection(aioclient_mock) diff --git a/tests/components/sonarr/test_sensor.py b/tests/components/sonarr/test_sensor.py index 3a11688a56f9..3f99325c3ef7 100644 --- a/tests/components/sonarr/test_sensor.py +++ b/tests/components/sonarr/test_sensor.py @@ -12,8 +12,8 @@ from homeassistant.const import ( DATA_GIGABYTES, STATE_UNAVAILABLE, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import dt as dt_util from tests.common import async_fire_time_changed @@ -24,7 +24,7 @@ UPCOMING_ENTITY_ID = f"{SENSOR_DOMAIN}.sonarr_upcoming" async def test_sensors( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test the creation and values of the sensors.""" entry = await setup_integration(hass, aioclient_mock, skip_entry_setup=True) @@ -104,7 +104,7 @@ async def test_sensors( ), ) async def test_disabled_by_default_sensors( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker, entity_id: str + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, entity_id: str ) -> None: """Test the disabled by default sensors.""" await setup_integration(hass, aioclient_mock) @@ -121,7 +121,7 @@ async def test_disabled_by_default_sensors( async def test_availability( - hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker ) -> None: """Test entity availability.""" now = dt_util.utcnow() diff --git a/tests/components/switcher_kis/test_init.py b/tests/components/switcher_kis/test_init.py index 394f48d001a4..14eb2a1a16e1 100644 --- a/tests/components/switcher_kis/test_init.py +++ b/tests/components/switcher_kis/test_init.py @@ -19,11 +19,10 @@ from homeassistant.components.switcher_kis.switch import ( SERVICE_TURN_ON_WITH_TIMER_NAME, ) from homeassistant.const import CONF_ENTITY_ID -from homeassistant.core import Context, callback +from homeassistant.core import Context, HomeAssistant, callback from homeassistant.exceptions import UnknownUser from homeassistant.helpers.config_validation import time_period_str from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.setup import async_setup_component from homeassistant.util import dt @@ -47,21 +46,21 @@ from tests.common import MockUser, async_fire_time_changed async def test_failed_config( - hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None] + hass: HomeAssistant, mock_failed_bridge: Generator[None, Any, None] ) -> None: """Test failed configuration.""" assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) is False async def test_minimal_config( - hass: HomeAssistantType, mock_bridge: Generator[None, Any, None] + hass: HomeAssistant, mock_bridge: Generator[None, Any, None] ) -> None: """Test setup with configuration minimal entries.""" assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) async def test_discovery_data_bucket( - hass: HomeAssistantType, mock_bridge: Generator[None, Any, None] + hass: HomeAssistant, mock_bridge: Generator[None, Any, None] ) -> None: """Test the event send with the updated device.""" assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) @@ -82,7 +81,7 @@ async def test_discovery_data_bucket( async def test_set_auto_off_service( - hass: HomeAssistantType, + hass: HomeAssistant, mock_bridge: Generator[None, Any, None], mock_api: Generator[None, Any, None], hass_owner_user: MockUser, @@ -130,7 +129,7 @@ async def test_set_auto_off_service( async def test_turn_on_with_timer_service( - hass: HomeAssistantType, + hass: HomeAssistant, mock_bridge: Generator[None, Any, None], mock_api: Generator[None, Any, None], hass_owner_user: MockUser, @@ -184,7 +183,7 @@ async def test_turn_on_with_timer_service( async def test_signal_dispatcher( - hass: HomeAssistantType, mock_bridge: Generator[None, Any, None] + hass: HomeAssistant, mock_bridge: Generator[None, Any, None] ) -> None: """Test signal dispatcher dispatching device updates every 4 seconds.""" assert await async_setup_component(hass, DOMAIN, MANDATORY_CONFIGURATION) diff --git a/tests/components/synology_dsm/test_config_flow.py b/tests/components/synology_dsm/test_config_flow.py index 85ed02a7a524..9c89ec64666a 100644 --- a/tests/components/synology_dsm/test_config_flow.py +++ b/tests/components/synology_dsm/test_config_flow.py @@ -36,7 +36,7 @@ from homeassistant.const import ( CONF_USERNAME, CONF_VERIFY_SSL, ) -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .consts import ( DEVICE_TOKEN, @@ -114,7 +114,7 @@ def mock_controller_service_failed(): yield service_mock -async def test_user(hass: HomeAssistantType, service: MagicMock): +async def test_user(hass: HomeAssistant, service: MagicMock): """Test user config.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=None @@ -177,7 +177,7 @@ async def test_user(hass: HomeAssistantType, service: MagicMock): assert result["data"].get(CONF_VOLUMES) is None -async def test_user_2sa(hass: HomeAssistantType, service_2sa: MagicMock): +async def test_user_2sa(hass: HomeAssistant, service_2sa: MagicMock): """Test user with 2sa authentication config.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -220,7 +220,7 @@ async def test_user_2sa(hass: HomeAssistantType, service_2sa: MagicMock): assert result["data"].get(CONF_VOLUMES) is None -async def test_user_vdsm(hass: HomeAssistantType, service_vdsm: MagicMock): +async def test_user_vdsm(hass: HomeAssistant, service_vdsm: MagicMock): """Test user config.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=None @@ -256,7 +256,7 @@ async def test_user_vdsm(hass: HomeAssistantType, service_vdsm: MagicMock): assert result["data"].get(CONF_VOLUMES) is None -async def test_import(hass: HomeAssistantType, service: MagicMock): +async def test_import(hass: HomeAssistant, service: MagicMock): """Test import step.""" # import with minimum setup result = await hass.config_entries.flow.async_init( @@ -309,7 +309,7 @@ async def test_import(hass: HomeAssistantType, service: MagicMock): assert result["data"][CONF_VOLUMES] == ["volume_1"] -async def test_abort_if_already_setup(hass: HomeAssistantType, service: MagicMock): +async def test_abort_if_already_setup(hass: HomeAssistant, service: MagicMock): """Test we abort if the account is already setup.""" MockConfigEntry( domain=DOMAIN, @@ -336,7 +336,7 @@ async def test_abort_if_already_setup(hass: HomeAssistantType, service: MagicMoc assert result["reason"] == "already_configured" -async def test_login_failed(hass: HomeAssistantType, service: MagicMock): +async def test_login_failed(hass: HomeAssistant, service: MagicMock): """Test when we have errors during login.""" service.return_value.login = Mock( side_effect=(SynologyDSMLoginInvalidException(USERNAME)) @@ -351,7 +351,7 @@ async def test_login_failed(hass: HomeAssistantType, service: MagicMock): assert result["errors"] == {CONF_USERNAME: "invalid_auth"} -async def test_connection_failed(hass: HomeAssistantType, service: MagicMock): +async def test_connection_failed(hass: HomeAssistant, service: MagicMock): """Test when we have errors during connection.""" service.return_value.login = Mock( side_effect=SynologyDSMRequestException(IOError("arg")) @@ -367,7 +367,7 @@ async def test_connection_failed(hass: HomeAssistantType, service: MagicMock): assert result["errors"] == {CONF_HOST: "cannot_connect"} -async def test_unknown_failed(hass: HomeAssistantType, service: MagicMock): +async def test_unknown_failed(hass: HomeAssistant, service: MagicMock): """Test when we have an unknown error.""" service.return_value.login = Mock(side_effect=SynologyDSMException(None, None)) @@ -381,9 +381,7 @@ async def test_unknown_failed(hass: HomeAssistantType, service: MagicMock): assert result["errors"] == {"base": "unknown"} -async def test_missing_data_after_login( - hass: HomeAssistantType, service_failed: MagicMock -): +async def test_missing_data_after_login(hass: HomeAssistant, service_failed: MagicMock): """Test when we have errors during connection.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -394,9 +392,7 @@ async def test_missing_data_after_login( assert result["errors"] == {"base": "missing_data"} -async def test_form_ssdp_already_configured( - hass: HomeAssistantType, service: MagicMock -): +async def test_form_ssdp_already_configured(hass: HomeAssistant, service: MagicMock): """Test ssdp abort when the serial number is already configured.""" await setup.async_setup_component(hass, "persistent_notification", {}) @@ -423,7 +419,7 @@ async def test_form_ssdp_already_configured( assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT -async def test_form_ssdp(hass: HomeAssistantType, service: MagicMock): +async def test_form_ssdp(hass: HomeAssistant, service: MagicMock): """Test we can setup from ssdp.""" await setup.async_setup_component(hass, "persistent_notification", {}) @@ -459,7 +455,7 @@ async def test_form_ssdp(hass: HomeAssistantType, service: MagicMock): assert result["data"].get(CONF_VOLUMES) is None -async def test_options_flow(hass: HomeAssistantType, service: MagicMock): +async def test_options_flow(hass: HomeAssistant, service: MagicMock): """Test config flow options.""" config_entry = MockConfigEntry( domain=DOMAIN, diff --git a/tests/components/synology_dsm/test_init.py b/tests/components/synology_dsm/test_init.py index 59864c565232..891296d97ea6 100644 --- a/tests/components/synology_dsm/test_init.py +++ b/tests/components/synology_dsm/test_init.py @@ -12,7 +12,7 @@ from homeassistant.const import ( CONF_SSL, CONF_USERNAME, ) -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .consts import HOST, MACS, PASSWORD, PORT, USE_SSL, USERNAME @@ -20,7 +20,7 @@ from tests.common import MockConfigEntry @pytest.mark.no_bypass_setup -async def test_services_registered(hass: HomeAssistantType): +async def test_services_registered(hass: HomeAssistant): """Test if all services are registered.""" with patch( "homeassistant.components.synology_dsm.SynoApi.async_setup", return_value=True