diff --git a/homeassistant/components/hyperion/__init__.py b/homeassistant/components/hyperion/__init__.py index 0aa94e13cac..74c6998dc01 100644 --- a/homeassistant/components/hyperion/__init__.py +++ b/homeassistant/components/hyperion/__init__.py @@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, ) -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from .const import ( CONF_INSTANCE_CLIENTS, @@ -290,16 +290,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b return True -async def _async_entry_updated( - hass: HomeAssistantType, config_entry: ConfigEntry -) -> None: +async def _async_entry_updated(hass: HomeAssistant, config_entry: ConfigEntry) -> None: """Handle entry updates.""" await hass.config_entries.async_reload(config_entry.entry_id) -async def async_unload_entry( - hass: HomeAssistantType, config_entry: ConfigEntry -) -> bool: +async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = all( await asyncio.gather( diff --git a/homeassistant/components/hyperion/light.py b/homeassistant/components/hyperion/light.py index f8d760c0a9f..4449b9baf71 100644 --- a/homeassistant/components/hyperion/light.py +++ b/homeassistant/components/hyperion/light.py @@ -19,12 +19,11 @@ from homeassistant.components.light import ( LightEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, ) -from homeassistant.helpers.typing import HomeAssistantType import homeassistant.util.color as color_util from . import ( @@ -81,7 +80,7 @@ ICON_EXTERNAL_SOURCE = "mdi:television-ambient-light" async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities: Callable + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable ) -> bool: """Set up a Hyperion platform from config entry.""" diff --git a/homeassistant/components/hyperion/switch.py b/homeassistant/components/hyperion/switch.py index 5a7dd0c2cf5..b7e7847e447 100644 --- a/homeassistant/components/hyperion/switch.py +++ b/homeassistant/components/hyperion/switch.py @@ -26,12 +26,11 @@ from hyperion.const import ( from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, ) -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import slugify from . import ( @@ -82,7 +81,7 @@ def _component_to_switch_name(component: str, instance_name: str) -> str: async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities: Callable + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable ) -> bool: """Set up a Hyperion platform from config entry.""" entry_data = hass.data[DOMAIN][config_entry.entry_id] diff --git a/homeassistant/components/iaqualink/__init__.py b/homeassistant/components/iaqualink/__init__.py index 0435645d87c..86dd6cb2932 100644 --- a/homeassistant/components/iaqualink/__init__.py +++ b/homeassistant/components/iaqualink/__init__.py @@ -27,6 +27,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv @@ -36,7 +37,7 @@ from homeassistant.helpers.dispatcher import ( ) from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, UPDATE_INTERVAL @@ -58,7 +59,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass: HomeAssistantType, config: ConfigType) -> None: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> None: """Set up the Aqualink component.""" conf = config.get(DOMAIN) @@ -74,7 +75,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> None: return True -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> None: +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: """Set up Aqualink from a config entry.""" username = entry.data[CONF_USERNAME] password = entry.data[CONF_PASSWORD] @@ -157,7 +158,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> None 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.""" forward_unload = hass.config_entries.async_forward_entry_unload diff --git a/homeassistant/components/iaqualink/binary_sensor.py b/homeassistant/components/iaqualink/binary_sensor.py index 07edc2dd2ea..26d446541e6 100644 --- a/homeassistant/components/iaqualink/binary_sensor.py +++ b/homeassistant/components/iaqualink/binary_sensor.py @@ -5,7 +5,7 @@ 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 . import AqualinkEntity from .const import DOMAIN as AQUALINK_DOMAIN @@ -14,7 +14,7 @@ PARALLEL_UPDATES = 0 async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up discovered binary sensors.""" devs = [] diff --git a/homeassistant/components/iaqualink/climate.py b/homeassistant/components/iaqualink/climate.py index 73988c4e523..13245429c0a 100644 --- a/homeassistant/components/iaqualink/climate.py +++ b/homeassistant/components/iaqualink/climate.py @@ -20,7 +20,7 @@ from homeassistant.components.climate.const import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from . import AqualinkEntity, refresh_system from .const import CLIMATE_SUPPORTED_MODES, DOMAIN as AQUALINK_DOMAIN @@ -31,7 +31,7 @@ PARALLEL_UPDATES = 0 async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up discovered switches.""" devs = [] diff --git a/homeassistant/components/iaqualink/light.py b/homeassistant/components/iaqualink/light.py index b86b2c00f57..79030e1e3ca 100644 --- a/homeassistant/components/iaqualink/light.py +++ b/homeassistant/components/iaqualink/light.py @@ -10,7 +10,7 @@ from homeassistant.components.light import ( LightEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from . import AqualinkEntity, refresh_system from .const import DOMAIN as AQUALINK_DOMAIN @@ -19,7 +19,7 @@ PARALLEL_UPDATES = 0 async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up discovered lights.""" devs = [] diff --git a/homeassistant/components/iaqualink/sensor.py b/homeassistant/components/iaqualink/sensor.py index eac6e2b7851..ae32db9eb9e 100644 --- a/homeassistant/components/iaqualink/sensor.py +++ b/homeassistant/components/iaqualink/sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from . import AqualinkEntity from .const import DOMAIN as AQUALINK_DOMAIN @@ -13,7 +13,7 @@ PARALLEL_UPDATES = 0 async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up discovered sensors.""" devs = [] diff --git a/homeassistant/components/iaqualink/switch.py b/homeassistant/components/iaqualink/switch.py index d19c334b461..a9fde150af3 100644 --- a/homeassistant/components/iaqualink/switch.py +++ b/homeassistant/components/iaqualink/switch.py @@ -1,7 +1,7 @@ """Support for Aqualink pool feature switches.""" from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from . import AqualinkEntity, refresh_system from .const import DOMAIN as AQUALINK_DOMAIN @@ -10,7 +10,7 @@ PARALLEL_UPDATES = 0 async def async_setup_entry( - hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities + hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up discovered switches.""" devs = [] diff --git a/homeassistant/components/icloud/__init__.py b/homeassistant/components/icloud/__init__.py index 6a3897a54c0..4bedb89ee0b 100644 --- a/homeassistant/components/icloud/__init__.py +++ b/homeassistant/components/icloud/__init__.py @@ -5,8 +5,9 @@ import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceDataType +from homeassistant.helpers.typing import ConfigType, ServiceDataType from homeassistant.util import slugify from .account import IcloudAccount @@ -86,7 +87,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up iCloud from legacy config file.""" conf = config.get(DOMAIN) @@ -103,7 +104,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> 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 an iCloud account from a config entry.""" hass.data.setdefault(DOMAIN, {}) @@ -221,7 +222,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool 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/icloud/account.py b/homeassistant/components/icloud/account.py index 5c3bd2bf519..55fd661768d 100644 --- a/homeassistant/components/icloud/account.py +++ b/homeassistant/components/icloud/account.py @@ -16,11 +16,11 @@ from pyicloud.services.findmyiphone import AppleDevice from homeassistant.components.zone import async_active_zone from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry from homeassistant.const import ATTR_ATTRIBUTION, CONF_USERNAME +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.dispatcher import dispatcher_send from homeassistant.helpers.event import track_point_in_utc_time from homeassistant.helpers.storage import Store -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import slugify from homeassistant.util.async_ import run_callback_threadsafe from homeassistant.util.dt import utcnow @@ -76,7 +76,7 @@ class IcloudAccount: def __init__( self, - hass: HomeAssistantType, + hass: HomeAssistant, username: str, password: str, icloud_dir: Store, diff --git a/homeassistant/components/icloud/device_tracker.py b/homeassistant/components/icloud/device_tracker.py index 502c2b00f8b..131f9335b43 100644 --- a/homeassistant/components/icloud/device_tracker.py +++ b/homeassistant/components/icloud/device_tracker.py @@ -4,9 +4,8 @@ from __future__ import annotations from homeassistant.components.device_tracker import SOURCE_TYPE_GPS from homeassistant.components.device_tracker.config_entry import TrackerEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.typing import HomeAssistantType from .account import IcloudAccount, IcloudDevice from .const import ( @@ -17,14 +16,12 @@ from .const import ( ) -async def async_setup_scanner( - hass: HomeAssistantType, config, see, discovery_info=None -): +async def async_setup_scanner(hass: HomeAssistant, config, see, discovery_info=None): """Old way of setting up the iCloud tracker.""" async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up device tracker for iCloud component.""" account = hass.data[DOMAIN][entry.unique_id] diff --git a/homeassistant/components/icloud/sensor.py b/homeassistant/components/icloud/sensor.py index f889495af25..3a875db81ed 100644 --- a/homeassistant/components/icloud/sensor.py +++ b/homeassistant/components/icloud/sensor.py @@ -4,17 +4,16 @@ from __future__ import annotations from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.icon import icon_for_battery_level -from homeassistant.helpers.typing import HomeAssistantType from .account import IcloudAccount, IcloudDevice from .const import DOMAIN async def async_setup_entry( - hass: HomeAssistantType, entry: ConfigEntry, async_add_entities + hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: """Set up device tracker for iCloud component.""" account = hass.data[DOMAIN][entry.unique_id] diff --git a/homeassistant/components/isy994/binary_sensor.py b/homeassistant/components/isy994/binary_sensor.py index 57b134e0900..6fe00c693bc 100644 --- a/homeassistant/components/isy994/binary_sensor.py +++ b/homeassistant/components/isy994/binary_sensor.py @@ -26,9 +26,8 @@ from homeassistant.components.binary_sensor import ( BinarySensorEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.event import async_track_point_in_utc_time -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import dt as dt_util from .const import ( @@ -60,7 +59,7 @@ DEVICE_PARENT_REQUIRED = [ async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/homeassistant/components/isy994/climate.py b/homeassistant/components/isy994/climate.py index 2c9aa52b3a7..efa09187453 100644 --- a/homeassistant/components/isy994/climate.py +++ b/homeassistant/components/isy994/climate.py @@ -34,7 +34,7 @@ from homeassistant.const import ( TEMP_CELSIUS, TEMP_FAHRENHEIT, ) -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import ( _LOGGER, @@ -61,7 +61,7 @@ ISY_SUPPORTED_FEATURES = ( async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/homeassistant/components/isy994/cover.py b/homeassistant/components/isy994/cover.py index bdc2bc7f6d4..65d91d24d24 100644 --- a/homeassistant/components/isy994/cover.py +++ b/homeassistant/components/isy994/cover.py @@ -12,7 +12,7 @@ from homeassistant.components.cover import ( CoverEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import ( _LOGGER, @@ -27,7 +27,7 @@ from .helpers import migrate_old_unique_ids async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/homeassistant/components/isy994/fan.py b/homeassistant/components/isy994/fan.py index 183d4b31d3b..e70201982b8 100644 --- a/homeassistant/components/isy994/fan.py +++ b/homeassistant/components/isy994/fan.py @@ -8,7 +8,7 @@ from pyisy.constants import ISY_VALUE_UNKNOWN, PROTO_INSTEON from homeassistant.components.fan import DOMAIN as FAN, SUPPORT_SET_SPEED, FanEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from homeassistant.util.percentage import ( int_states_in_range, percentage_to_ranged_value, @@ -23,7 +23,7 @@ SPEED_RANGE = (1, 255) # off is not included async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/homeassistant/components/isy994/helpers.py b/homeassistant/components/isy994/helpers.py index 81a74430d3a..5322c8e0abf 100644 --- a/homeassistant/components/isy994/helpers.py +++ b/homeassistant/components/isy994/helpers.py @@ -21,8 +21,8 @@ from homeassistant.components.fan import DOMAIN as FAN from homeassistant.components.light import DOMAIN as LIGHT from homeassistant.components.sensor import DOMAIN as SENSOR from homeassistant.components.switch import DOMAIN as SWITCH +from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import async_get_registry -from homeassistant.helpers.typing import HomeAssistantType from .const import ( _LOGGER, @@ -366,7 +366,7 @@ def _categorize_variables( async def migrate_old_unique_ids( - hass: HomeAssistantType, platform: str, devices: list[Any] | None + hass: HomeAssistant, platform: str, devices: list[Any] | None ) -> None: """Migrate to new controller-specific unique ids.""" registry = await async_get_registry(hass) diff --git a/homeassistant/components/isy994/light.py b/homeassistant/components/isy994/light.py index 7f35e96acaf..4cb42492daf 100644 --- a/homeassistant/components/isy994/light.py +++ b/homeassistant/components/isy994/light.py @@ -11,8 +11,8 @@ from homeassistant.components.light import ( LightEntity, ) from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant from homeassistant.helpers.restore_state import RestoreEntity -from homeassistant.helpers.typing import HomeAssistantType from .const import ( _LOGGER, @@ -29,7 +29,7 @@ ATTR_LAST_BRIGHTNESS = "last_brightness" async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/homeassistant/components/isy994/lock.py b/homeassistant/components/isy994/lock.py index ceb26f3044c..e8db796805b 100644 --- a/homeassistant/components/isy994/lock.py +++ b/homeassistant/components/isy994/lock.py @@ -5,7 +5,7 @@ from pyisy.constants import ISY_VALUE_UNKNOWN from homeassistant.components.lock import DOMAIN as LOCK, LockEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import _LOGGER, DOMAIN as ISY994_DOMAIN, ISY994_NODES, ISY994_PROGRAMS from .entity import ISYNodeEntity, ISYProgramEntity @@ -15,7 +15,7 @@ VALUE_TO_STATE = {0: False, 100: True} async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/homeassistant/components/isy994/sensor.py b/homeassistant/components/isy994/sensor.py index 2927fbb62b1..1c560c924ca 100644 --- a/homeassistant/components/isy994/sensor.py +++ b/homeassistant/components/isy994/sensor.py @@ -8,7 +8,7 @@ from pyisy.constants import ISY_VALUE_UNKNOWN from homeassistant.components.sensor import DOMAIN as SENSOR, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from .const import ( _LOGGER, @@ -26,7 +26,7 @@ from .helpers import convert_isy_value_to_hass, migrate_old_unique_ids async def async_setup_entry( - hass: HomeAssistantType, + hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: diff --git a/tests/components/hyperion/__init__.py b/tests/components/hyperion/__init__.py index 7938527a12d..ac77a5a0407 100644 --- a/tests/components/hyperion/__init__.py +++ b/tests/components/hyperion/__init__.py @@ -11,8 +11,8 @@ from homeassistant.components.hyperion import get_hyperion_unique_id from homeassistant.components.hyperion.const import CONF_PRIORITY, DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from homeassistant.helpers.typing import HomeAssistantType from tests.common import MockConfigEntry @@ -120,7 +120,7 @@ def create_mock_client() -> Mock: def add_test_config_entry( - hass: HomeAssistantType, + hass: HomeAssistant, data: dict[str, Any] | None = None, options: dict[str, Any] | None = None, ) -> ConfigEntry: @@ -142,7 +142,7 @@ def add_test_config_entry( async def setup_test_config_entry( - hass: HomeAssistantType, + hass: HomeAssistant, config_entry: ConfigEntry | None = None, hyperion_client: Mock | None = None, options: dict[str, Any] | None = None, @@ -173,7 +173,7 @@ def call_registered_callback( def register_test_entity( - hass: HomeAssistantType, domain: str, type_name: str, entity_id: str + hass: HomeAssistant, domain: str, type_name: str, entity_id: str ) -> None: """Register a test entity.""" unique_id = get_hyperion_unique_id(TEST_SYSINFO_ID, TEST_INSTANCE, type_name) diff --git a/tests/components/hyperion/test_config_flow.py b/tests/components/hyperion/test_config_flow.py index 381dc018407..d8b12e3c72b 100644 --- a/tests/components/hyperion/test_config_flow.py +++ b/tests/components/hyperion/test_config_flow.py @@ -25,7 +25,7 @@ from homeassistant.const import ( CONF_TOKEN, SERVICE_TURN_ON, ) -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from . import ( TEST_AUTH_REQUIRED_RESP, @@ -98,7 +98,7 @@ TEST_SSDP_SERVICE_INFO = { } -async def _create_mock_entry(hass: HomeAssistantType) -> MockConfigEntry: +async def _create_mock_entry(hass: HomeAssistant) -> MockConfigEntry: """Add a test Hyperion entity to hass.""" entry: MockConfigEntry = MockConfigEntry( # type: ignore[no-untyped-call] entry_id=TEST_CONFIG_ENTRY_ID, @@ -125,7 +125,7 @@ async def _create_mock_entry(hass: HomeAssistantType) -> MockConfigEntry: async def _init_flow( - hass: HomeAssistantType, + hass: HomeAssistant, source: str = SOURCE_USER, data: dict[str, Any] | None = None, ) -> Any: @@ -138,7 +138,7 @@ async def _init_flow( async def _configure_flow( - hass: HomeAssistantType, result: dict, user_input: dict[str, Any] | None = None + hass: HomeAssistant, result: dict, user_input: dict[str, Any] | None = None ) -> Any: """Provide input to a flow.""" user_input = user_input or {} @@ -156,7 +156,7 @@ async def _configure_flow( return result -async def test_user_if_no_configuration(hass: HomeAssistantType) -> None: +async def test_user_if_no_configuration(hass: HomeAssistant) -> None: """Check flow behavior when no configuration is present.""" result = await _init_flow(hass) @@ -165,7 +165,7 @@ async def test_user_if_no_configuration(hass: HomeAssistantType) -> None: assert result["handler"] == DOMAIN -async def test_user_existing_id_abort(hass: HomeAssistantType) -> None: +async def test_user_existing_id_abort(hass: HomeAssistant) -> None: """Verify a duplicate ID results in an abort.""" result = await _init_flow(hass) @@ -179,7 +179,7 @@ async def test_user_existing_id_abort(hass: HomeAssistantType) -> None: assert result["reason"] == "already_configured" -async def test_user_client_errors(hass: HomeAssistantType) -> None: +async def test_user_client_errors(hass: HomeAssistant) -> None: """Verify correct behaviour with client errors.""" result = await _init_flow(hass) @@ -205,7 +205,7 @@ async def test_user_client_errors(hass: HomeAssistantType) -> None: assert result["reason"] == "auth_required_error" -async def test_user_confirm_cannot_connect(hass: HomeAssistantType) -> None: +async def test_user_confirm_cannot_connect(hass: HomeAssistant) -> None: """Test a failure to connect during confirmation.""" result = await _init_flow(hass) @@ -224,7 +224,7 @@ async def test_user_confirm_cannot_connect(hass: HomeAssistantType) -> None: assert result["reason"] == "cannot_connect" -async def test_user_confirm_id_error(hass: HomeAssistantType) -> None: +async def test_user_confirm_id_error(hass: HomeAssistant) -> None: """Test a failure fetching the server id during confirmation.""" result = await _init_flow(hass) @@ -240,7 +240,7 @@ async def test_user_confirm_id_error(hass: HomeAssistantType) -> None: assert result["reason"] == "no_id" -async def test_user_noauth_flow_success(hass: HomeAssistantType) -> None: +async def test_user_noauth_flow_success(hass: HomeAssistant) -> None: """Check a full flow without auth.""" result = await _init_flow(hass) @@ -258,7 +258,7 @@ async def test_user_noauth_flow_success(hass: HomeAssistantType) -> None: } -async def test_user_auth_required(hass: HomeAssistantType) -> None: +async def test_user_auth_required(hass: HomeAssistant) -> None: """Verify correct behaviour when auth is required.""" result = await _init_flow(hass) @@ -273,7 +273,7 @@ async def test_user_auth_required(hass: HomeAssistantType) -> None: assert result["step_id"] == "auth" -async def test_auth_static_token_auth_required_fail(hass: HomeAssistantType) -> None: +async def test_auth_static_token_auth_required_fail(hass: HomeAssistant) -> None: """Verify correct behaviour with a failed auth required call.""" result = await _init_flow(hass) @@ -287,7 +287,7 @@ async def test_auth_static_token_auth_required_fail(hass: HomeAssistantType) -> assert result["reason"] == "auth_required_error" -async def test_auth_static_token_success(hass: HomeAssistantType) -> None: +async def test_auth_static_token_success(hass: HomeAssistant) -> None: """Test a successful flow with a static token.""" result = await _init_flow(hass) assert result["step_id"] == "user" @@ -312,7 +312,7 @@ async def test_auth_static_token_success(hass: HomeAssistantType) -> None: } -async def test_auth_static_token_login_connect_fail(hass: HomeAssistantType) -> None: +async def test_auth_static_token_login_connect_fail(hass: HomeAssistant) -> None: """Test correct behavior with a static token that cannot connect.""" result = await _init_flow(hass) assert result["step_id"] == "user" @@ -333,7 +333,7 @@ async def test_auth_static_token_login_connect_fail(hass: HomeAssistantType) -> assert result["reason"] == "cannot_connect" -async def test_auth_static_token_login_fail(hass: HomeAssistantType) -> None: +async def test_auth_static_token_login_fail(hass: HomeAssistant) -> None: """Test correct behavior with a static token that cannot login.""" result = await _init_flow(hass) assert result["step_id"] == "user" @@ -356,7 +356,7 @@ async def test_auth_static_token_login_fail(hass: HomeAssistantType) -> None: assert result["errors"]["base"] == "invalid_access_token" -async def test_auth_create_token_approval_declined(hass: HomeAssistantType) -> None: +async def test_auth_create_token_approval_declined(hass: HomeAssistant) -> None: """Verify correct behaviour when a token request is declined.""" result = await _init_flow(hass) @@ -400,7 +400,7 @@ async def test_auth_create_token_approval_declined(hass: HomeAssistantType) -> N async def test_auth_create_token_approval_declined_task_canceled( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Verify correct behaviour when a token request is declined.""" result = await _init_flow(hass) @@ -461,7 +461,7 @@ async def test_auth_create_token_approval_declined_task_canceled( async def test_auth_create_token_when_issued_token_fails( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Verify correct behaviour when a token is granted by fails to authenticate.""" result = await _init_flow(hass) @@ -506,7 +506,7 @@ async def test_auth_create_token_when_issued_token_fails( assert result["reason"] == "cannot_connect" -async def test_auth_create_token_success(hass: HomeAssistantType) -> None: +async def test_auth_create_token_success(hass: HomeAssistant) -> None: """Verify correct behaviour when a token is successfully created.""" result = await _init_flow(hass) @@ -552,7 +552,7 @@ async def test_auth_create_token_success(hass: HomeAssistantType) -> None: async def test_auth_create_token_success_but_login_fail( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Verify correct behaviour when a token is successfully created but the login fails.""" result = await _init_flow(hass) @@ -592,7 +592,7 @@ async def test_auth_create_token_success_but_login_fail( assert result["reason"] == "auth_new_token_not_work_error" -async def test_ssdp_success(hass: HomeAssistantType) -> None: +async def test_ssdp_success(hass: HomeAssistant) -> None: """Check an SSDP flow.""" client = create_mock_client() @@ -617,7 +617,7 @@ async def test_ssdp_success(hass: HomeAssistantType) -> None: } -async def test_ssdp_cannot_connect(hass: HomeAssistantType) -> None: +async def test_ssdp_cannot_connect(hass: HomeAssistant) -> None: """Check an SSDP flow that cannot connect.""" client = create_mock_client() @@ -633,7 +633,7 @@ async def test_ssdp_cannot_connect(hass: HomeAssistantType) -> None: assert result["reason"] == "cannot_connect" -async def test_ssdp_missing_serial(hass: HomeAssistantType) -> None: +async def test_ssdp_missing_serial(hass: HomeAssistant) -> None: """Check an SSDP flow where no id is provided.""" client = create_mock_client() @@ -650,7 +650,7 @@ async def test_ssdp_missing_serial(hass: HomeAssistantType) -> None: assert result["reason"] == "no_id" -async def test_ssdp_failure_bad_port_json(hass: HomeAssistantType) -> None: +async def test_ssdp_failure_bad_port_json(hass: HomeAssistant) -> None: """Check an SSDP flow with bad json port.""" client = create_mock_client() @@ -668,7 +668,7 @@ async def test_ssdp_failure_bad_port_json(hass: HomeAssistantType) -> None: assert result["data"][CONF_PORT] == const.DEFAULT_PORT_JSON -async def test_ssdp_failure_bad_port_ui(hass: HomeAssistantType) -> None: +async def test_ssdp_failure_bad_port_ui(hass: HomeAssistant) -> None: """Check an SSDP flow with bad ui port.""" client = create_mock_client() @@ -703,7 +703,7 @@ async def test_ssdp_failure_bad_port_ui(hass: HomeAssistantType) -> None: } -async def test_ssdp_abort_duplicates(hass: HomeAssistantType) -> None: +async def test_ssdp_abort_duplicates(hass: HomeAssistant) -> None: """Check an SSDP flow where no id is provided.""" client = create_mock_client() @@ -723,7 +723,7 @@ async def test_ssdp_abort_duplicates(hass: HomeAssistantType) -> None: assert result_2["reason"] == "already_in_progress" -async def test_options_priority(hass: HomeAssistantType) -> None: +async def test_options_priority(hass: HomeAssistant) -> None: """Check an options flow priority option.""" config_entry = add_test_config_entry(hass) @@ -761,7 +761,7 @@ async def test_options_priority(hass: HomeAssistantType) -> None: assert client.async_send_set_color.call_args[1][CONF_PRIORITY] == new_priority -async def test_options_effect_show_list(hass: HomeAssistantType) -> None: +async def test_options_effect_show_list(hass: HomeAssistant) -> None: """Check an options flow effect show list.""" config_entry = add_test_config_entry(hass) @@ -795,7 +795,7 @@ async def test_options_effect_show_list(hass: HomeAssistantType) -> None: ) -async def test_options_effect_hide_list_cannot_connect(hass: HomeAssistantType) -> None: +async def test_options_effect_hide_list_cannot_connect(hass: HomeAssistant) -> None: """Check an options flow effect hide list with a failed connection.""" config_entry = add_test_config_entry(hass) @@ -814,7 +814,7 @@ async def test_options_effect_hide_list_cannot_connect(hass: HomeAssistantType) assert result["reason"] == "cannot_connect" -async def test_reauth_success(hass: HomeAssistantType) -> None: +async def test_reauth_success(hass: HomeAssistant) -> None: """Check a reauth flow that succeeds.""" config_data = { @@ -848,7 +848,7 @@ async def test_reauth_success(hass: HomeAssistantType) -> None: assert CONF_TOKEN in config_entry.data -async def test_reauth_cannot_connect(hass: HomeAssistantType) -> None: +async def test_reauth_cannot_connect(hass: HomeAssistant) -> None: """Check a reauth flow that fails to connect.""" config_data = { diff --git a/tests/components/hyperion/test_light.py b/tests/components/hyperion/test_light.py index e0ab681b7a3..de0110cb19f 100644 --- a/tests/components/hyperion/test_light.py +++ b/tests/components/hyperion/test_light.py @@ -39,8 +39,8 @@ from homeassistant.const import ( SERVICE_TURN_OFF, SERVICE_TURN_ON, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import dt import homeassistant.util.color as color_util @@ -74,7 +74,7 @@ COLOR_BLACK = color_util.COLORS["black"] def _get_config_entry_from_unique_id( - hass: HomeAssistantType, unique_id: str + hass: HomeAssistant, unique_id: str ) -> ConfigEntry | None: for entry in hass.config_entries.async_entries(domain=DOMAIN): if TEST_SYSINFO_ID == entry.unique_id: @@ -82,14 +82,14 @@ def _get_config_entry_from_unique_id( return None -async def test_setup_config_entry(hass: HomeAssistantType) -> None: +async def test_setup_config_entry(hass: HomeAssistant) -> None: """Test setting up the component via config entries.""" await setup_test_config_entry(hass, hyperion_client=create_mock_client()) assert hass.states.get(TEST_ENTITY_ID_1) is not None async def test_setup_config_entry_not_ready_connect_fail( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test the component not being ready.""" client = create_mock_client() @@ -99,7 +99,7 @@ async def test_setup_config_entry_not_ready_connect_fail( async def test_setup_config_entry_not_ready_switch_instance_fail( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test the component not being ready.""" client = create_mock_client() @@ -110,7 +110,7 @@ async def test_setup_config_entry_not_ready_switch_instance_fail( async def test_setup_config_entry_not_ready_load_state_fail( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test the component not being ready.""" client = create_mock_client() @@ -126,7 +126,7 @@ async def test_setup_config_entry_not_ready_load_state_fail( assert hass.states.get(TEST_ENTITY_ID_1) is None -async def test_setup_config_entry_dynamic_instances(hass: HomeAssistantType) -> None: +async def test_setup_config_entry_dynamic_instances(hass: HomeAssistant) -> None: """Test dynamic changes in the instance configuration.""" registry = er.async_get(hass) @@ -241,7 +241,7 @@ async def test_setup_config_entry_dynamic_instances(hass: HomeAssistantType) -> assert hass.states.get(TEST_ENTITY_ID_3) is not None -async def test_light_basic_properies(hass: HomeAssistantType) -> None: +async def test_light_basic_properies(hass: HomeAssistant) -> None: """Test the basic properties.""" client = create_mock_client() await setup_test_config_entry(hass, hyperion_client=client) @@ -262,7 +262,7 @@ async def test_light_basic_properies(hass: HomeAssistantType) -> None: ) -async def test_light_async_turn_on(hass: HomeAssistantType) -> None: +async def test_light_async_turn_on(hass: HomeAssistant) -> None: """Test turning the light on.""" client = create_mock_client() await setup_test_config_entry(hass, hyperion_client=client) @@ -507,7 +507,7 @@ async def test_light_async_turn_on(hass: HomeAssistantType) -> None: async def test_light_async_turn_on_fail_async_send_set_component( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test set_component failure when turning the light on.""" client = create_mock_client() @@ -523,7 +523,7 @@ async def test_light_async_turn_on_fail_async_send_set_component( async def test_light_async_turn_on_fail_async_send_set_component_source( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_set_component failure when selecting the source.""" client = create_mock_client() @@ -546,7 +546,7 @@ async def test_light_async_turn_on_fail_async_send_set_component_source( async def test_light_async_turn_on_fail_async_send_clear_source( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_clear failure when turning the light on.""" client = create_mock_client() @@ -566,7 +566,7 @@ async def test_light_async_turn_on_fail_async_send_clear_source( async def test_light_async_turn_on_fail_async_send_clear_effect( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_clear failure when turning on an effect.""" client = create_mock_client() @@ -583,7 +583,7 @@ async def test_light_async_turn_on_fail_async_send_clear_effect( async def test_light_async_turn_on_fail_async_send_set_effect( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_set_effect failure when turning on the light.""" client = create_mock_client() @@ -603,7 +603,7 @@ async def test_light_async_turn_on_fail_async_send_set_effect( async def test_light_async_turn_on_fail_async_send_set_color( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_set_color failure when turning on the light.""" client = create_mock_client() @@ -623,7 +623,7 @@ async def test_light_async_turn_on_fail_async_send_set_color( async def test_light_async_turn_off_fail_async_send_set_component( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_set_component failure when turning off the light.""" client = create_mock_client() @@ -642,7 +642,7 @@ async def test_light_async_turn_off_fail_async_send_set_component( async def test_priority_light_async_turn_off_fail_async_send_clear( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test async_send_clear failure when turning off a priority light.""" client = create_mock_client() @@ -662,7 +662,7 @@ async def test_priority_light_async_turn_off_fail_async_send_clear( assert client.method_calls[-1] == call.async_send_clear(priority=180) -async def test_light_async_turn_off(hass: HomeAssistantType) -> None: +async def test_light_async_turn_off(hass: HomeAssistant) -> None: """Test turning the light off.""" client = create_mock_client() await setup_test_config_entry(hass, hyperion_client=client) @@ -705,7 +705,7 @@ async def test_light_async_turn_off(hass: HomeAssistantType) -> None: async def test_light_async_updates_from_hyperion_client( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test receiving a variety of Hyperion client callbacks.""" client = create_mock_client() @@ -825,7 +825,7 @@ async def test_light_async_updates_from_hyperion_client( assert entity_state.state == "on" -async def test_full_state_loaded_on_start(hass: HomeAssistantType) -> None: +async def test_full_state_loaded_on_start(hass: HomeAssistant) -> None: """Test receiving a variety of Hyperion client callbacks.""" client = create_mock_client() @@ -848,7 +848,7 @@ async def test_full_state_loaded_on_start(hass: HomeAssistantType) -> None: assert entity_state.attributes["hs_color"] == (180.0, 100.0) -async def test_unload_entry(hass: HomeAssistantType) -> None: +async def test_unload_entry(hass: HomeAssistant) -> None: """Test unload.""" client = create_mock_client() await setup_test_config_entry(hass, hyperion_client=client) @@ -862,7 +862,7 @@ async def test_unload_entry(hass: HomeAssistantType) -> None: assert client.async_client_disconnect.call_count == 2 -async def test_version_log_warning(caplog, hass: HomeAssistantType) -> None: # type: ignore[no-untyped-def] +async def test_version_log_warning(caplog, hass: HomeAssistant) -> None: # type: ignore[no-untyped-def] """Test warning on old version.""" client = create_mock_client() client.async_sysinfo_version = AsyncMock(return_value="2.0.0-alpha.7") @@ -871,7 +871,7 @@ async def test_version_log_warning(caplog, hass: HomeAssistantType) -> None: # assert "Please consider upgrading" in caplog.text -async def test_version_no_log_warning(caplog, hass: HomeAssistantType) -> None: # type: ignore[no-untyped-def] +async def test_version_no_log_warning(caplog, hass: HomeAssistant) -> None: # type: ignore[no-untyped-def] """Test no warning on acceptable version.""" client = create_mock_client() client.async_sysinfo_version = AsyncMock(return_value="2.0.0-alpha.9") @@ -880,7 +880,7 @@ async def test_version_no_log_warning(caplog, hass: HomeAssistantType) -> None: assert "Please consider upgrading" not in caplog.text -async def test_setup_entry_no_token_reauth(hass: HomeAssistantType) -> None: +async def test_setup_entry_no_token_reauth(hass: HomeAssistant) -> None: """Verify a reauth flow when auth is required but no token provided.""" client = create_mock_client() config_entry = add_test_config_entry(hass) @@ -903,7 +903,7 @@ async def test_setup_entry_no_token_reauth(hass: HomeAssistantType) -> None: assert config_entry.state == ENTRY_STATE_SETUP_ERROR -async def test_setup_entry_bad_token_reauth(hass: HomeAssistantType) -> None: +async def test_setup_entry_bad_token_reauth(hass: HomeAssistant) -> None: """Verify a reauth flow when a bad token is provided.""" client = create_mock_client() config_entry = add_test_config_entry( @@ -932,7 +932,7 @@ async def test_setup_entry_bad_token_reauth(hass: HomeAssistantType) -> None: async def test_priority_light_async_updates( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test receiving a variety of Hyperion client callbacks to a HyperionPriorityLight.""" priority_template = { @@ -1094,7 +1094,7 @@ async def test_priority_light_async_updates( async def test_priority_light_async_updates_off_sets_black( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test turning the HyperionPriorityLight off.""" client = create_mock_client() @@ -1142,7 +1142,7 @@ async def test_priority_light_async_updates_off_sets_black( async def test_priority_light_prior_color_preserved_after_black( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test that color is preserved in an on->off->on cycle for a HyperionPriorityLight. @@ -1265,7 +1265,7 @@ async def test_priority_light_prior_color_preserved_after_black( assert entity_state.attributes["hs_color"] == hs_color -async def test_priority_light_has_no_external_sources(hass: HomeAssistantType) -> None: +async def test_priority_light_has_no_external_sources(hass: HomeAssistant) -> None: """Ensure a HyperionPriorityLight does not list external sources.""" client = create_mock_client() client.priorities = [] @@ -1283,7 +1283,7 @@ async def test_priority_light_has_no_external_sources(hass: HomeAssistantType) - assert entity_state.attributes["effect_list"] == [hyperion_light.KEY_EFFECT_SOLID] -async def test_light_option_effect_hide_list(hass: HomeAssistantType) -> None: +async def test_light_option_effect_hide_list(hass: HomeAssistant) -> None: """Test the effect_hide_list option.""" client = create_mock_client() client.effects = [{const.KEY_NAME: "One"}, {const.KEY_NAME: "Two"}] @@ -1304,7 +1304,7 @@ async def test_light_option_effect_hide_list(hass: HomeAssistantType) -> None: ] -async def test_device_info(hass: HomeAssistantType) -> None: +async def test_device_info(hass: HomeAssistant) -> None: """Verify device information includes expected details.""" client = create_mock_client() @@ -1336,7 +1336,7 @@ async def test_device_info(hass: HomeAssistantType) -> None: assert TEST_ENTITY_ID_1 in entities_from_device -async def test_lights_can_be_enabled(hass: HomeAssistantType) -> None: +async def test_lights_can_be_enabled(hass: HomeAssistant) -> None: """Verify lights can be enabled.""" client = create_mock_client() await setup_test_config_entry(hass, hyperion_client=client) @@ -1369,7 +1369,7 @@ async def test_lights_can_be_enabled(hass: HomeAssistantType) -> None: assert entity_state -async def test_deprecated_effect_names(caplog, hass: HomeAssistantType) -> None: # type: ignore[no-untyped-def] +async def test_deprecated_effect_names(caplog, hass: HomeAssistant) -> None: # type: ignore[no-untyped-def] """Test deprecated effects function and issue a warning.""" client = create_mock_client() client.async_send_clear = AsyncMock(return_value=True) @@ -1401,7 +1401,7 @@ async def test_deprecated_effect_names(caplog, hass: HomeAssistantType) -> None: async def test_deprecated_effect_names_not_in_effect_list( - hass: HomeAssistantType, + hass: HomeAssistant, ) -> None: """Test deprecated effects are not in shown effect list.""" await setup_test_config_entry(hass) diff --git a/tests/components/hyperion/test_switch.py b/tests/components/hyperion/test_switch.py index 764f234eb0e..2367ad96133 100644 --- a/tests/components/hyperion/test_switch.py +++ b/tests/components/hyperion/test_switch.py @@ -20,8 +20,8 @@ from homeassistant.components.hyperion.const import ( from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON +from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import dt, slugify from . import ( @@ -52,7 +52,7 @@ TEST_SWITCH_COMPONENT_BASE_ENTITY_ID = "switch.test_instance_1_component" TEST_SWITCH_COMPONENT_ALL_ENTITY_ID = f"{TEST_SWITCH_COMPONENT_BASE_ENTITY_ID}_all" -async def test_switch_turn_on_off(hass: HomeAssistantType) -> None: +async def test_switch_turn_on_off(hass: HomeAssistant) -> None: """Test turning the light on.""" client = create_mock_client() client.async_send_set_component = AsyncMock(return_value=True) @@ -121,7 +121,7 @@ async def test_switch_turn_on_off(hass: HomeAssistantType) -> None: assert entity_state.state == "on" -async def test_switch_has_correct_entities(hass: HomeAssistantType) -> None: +async def test_switch_has_correct_entities(hass: HomeAssistant) -> None: """Test that the correct switch entities are created.""" client = create_mock_client() client.components = TEST_COMPONENTS @@ -144,7 +144,7 @@ async def test_switch_has_correct_entities(hass: HomeAssistantType) -> None: assert entity_state, f"Couldn't find entity: {entity_id}" -async def test_device_info(hass: HomeAssistantType) -> None: +async def test_device_info(hass: HomeAssistant) -> None: """Verify device information includes expected details.""" client = create_mock_client() client.components = TEST_COMPONENTS @@ -184,7 +184,7 @@ async def test_device_info(hass: HomeAssistantType) -> None: assert entity_id in entities_from_device -async def test_switches_can_be_enabled(hass: HomeAssistantType) -> None: +async def test_switches_can_be_enabled(hass: HomeAssistant) -> None: """Verify switches can be enabled.""" client = create_mock_client() client.components = TEST_COMPONENTS diff --git a/tests/components/icloud/test_config_flow.py b/tests/components/icloud/test_config_flow.py index 998a69c575a..59c5ebf24a9 100644 --- a/tests/components/icloud/test_config_flow.py +++ b/tests/components/icloud/test_config_flow.py @@ -20,7 +20,7 @@ from homeassistant.components.icloud.const import ( ) from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER from homeassistant.const import CONF_PASSWORD, CONF_USERNAME -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry @@ -157,7 +157,7 @@ def mock_controller_service_validate_verification_code_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 @@ -175,9 +175,7 @@ async def test_user(hass: HomeAssistantType, service: MagicMock): assert result["step_id"] == CONF_TRUSTED_DEVICE -async def test_user_with_cookie( - hass: HomeAssistantType, service_authenticated: MagicMock -): +async def test_user_with_cookie(hass: HomeAssistant, service_authenticated: MagicMock): """Test user config with presence of a cookie.""" # test with all provided result = await hass.config_entries.flow.async_init( @@ -199,7 +197,7 @@ async def test_user_with_cookie( assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD -async def test_import(hass: HomeAssistantType, service: MagicMock): +async def test_import(hass: HomeAssistant, service: MagicMock): """Test import step.""" # import with required result = await hass.config_entries.flow.async_init( @@ -227,7 +225,7 @@ async def test_import(hass: HomeAssistantType, service: MagicMock): async def test_import_with_cookie( - hass: HomeAssistantType, service_authenticated: MagicMock + hass: HomeAssistant, service_authenticated: MagicMock ): """Test import step with presence of a cookie.""" # import with required @@ -268,7 +266,7 @@ async def test_import_with_cookie( async def test_two_accounts_setup( - hass: HomeAssistantType, service_authenticated: MagicMock + hass: HomeAssistant, service_authenticated: MagicMock ): """Test to setup two accounts.""" MockConfigEntry( @@ -293,7 +291,7 @@ async def test_two_accounts_setup( assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD -async def test_already_setup(hass: HomeAssistantType): +async def test_already_setup(hass: HomeAssistant): """Test we abort if the account is already setup.""" MockConfigEntry( domain=DOMAIN, @@ -320,7 +318,7 @@ async def test_already_setup(hass: HomeAssistantType): assert result["reason"] == "already_configured" -async def test_login_failed(hass: HomeAssistantType): +async def test_login_failed(hass: HomeAssistant): """Test when we have errors during login.""" with patch( "homeassistant.components.icloud.config_flow.PyiCloudService.authenticate", @@ -336,7 +334,7 @@ async def test_login_failed(hass: HomeAssistantType): async def test_no_device( - hass: HomeAssistantType, service_authenticated_no_device: MagicMock + hass: HomeAssistant, service_authenticated_no_device: MagicMock ): """Test when we have no devices.""" result = await hass.config_entries.flow.async_init( @@ -348,7 +346,7 @@ async def test_no_device( assert result["reason"] == "no_device" -async def test_trusted_device(hass: HomeAssistantType, service: MagicMock): +async def test_trusted_device(hass: HomeAssistant, service: MagicMock): """Test trusted_device step.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -361,7 +359,7 @@ async def test_trusted_device(hass: HomeAssistantType, service: MagicMock): assert result["step_id"] == CONF_TRUSTED_DEVICE -async def test_trusted_device_success(hass: HomeAssistantType, service: MagicMock): +async def test_trusted_device_success(hass: HomeAssistant, service: MagicMock): """Test trusted_device step success.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -377,7 +375,7 @@ async def test_trusted_device_success(hass: HomeAssistantType, service: MagicMoc async def test_send_verification_code_failed( - hass: HomeAssistantType, service_send_verification_code_failed: MagicMock + hass: HomeAssistant, service_send_verification_code_failed: MagicMock ): """Test when we have errors during send_verification_code.""" result = await hass.config_entries.flow.async_init( @@ -394,7 +392,7 @@ async def test_send_verification_code_failed( assert result["errors"] == {CONF_TRUSTED_DEVICE: "send_verification_code"} -async def test_verification_code(hass: HomeAssistantType, service: MagicMock): +async def test_verification_code(hass: HomeAssistant, service: MagicMock): """Test verification_code step.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -410,7 +408,7 @@ async def test_verification_code(hass: HomeAssistantType, service: MagicMock): assert result["step_id"] == CONF_VERIFICATION_CODE -async def test_verification_code_success(hass: HomeAssistantType, service: MagicMock): +async def test_verification_code_success(hass: HomeAssistant, service: MagicMock): """Test verification_code step success.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -436,7 +434,7 @@ async def test_verification_code_success(hass: HomeAssistantType, service: Magic async def test_validate_verification_code_failed( - hass: HomeAssistantType, service_validate_verification_code_failed: MagicMock + hass: HomeAssistant, service_validate_verification_code_failed: MagicMock ): """Test when we have errors during validate_verification_code.""" result = await hass.config_entries.flow.async_init( @@ -456,7 +454,7 @@ async def test_validate_verification_code_failed( assert result["errors"] == {"base": "validate_verification_code"} -async def test_2fa_code_success(hass: HomeAssistantType, service_2fa: MagicMock): +async def test_2fa_code_success(hass: HomeAssistant, service_2fa: MagicMock): """Test 2fa step success.""" result = await hass.config_entries.flow.async_init( DOMAIN, @@ -481,7 +479,7 @@ async def test_2fa_code_success(hass: HomeAssistantType, service_2fa: MagicMock) async def test_validate_2fa_code_failed( - hass: HomeAssistantType, service_validate_2fa_code_failed: MagicMock + hass: HomeAssistant, service_validate_2fa_code_failed: MagicMock ): """Test when we have errors during validate_verification_code.""" result = await hass.config_entries.flow.async_init( @@ -499,9 +497,7 @@ async def test_validate_2fa_code_failed( assert result["errors"] == {"base": "validate_verification_code"} -async def test_password_update( - hass: HomeAssistantType, service_authenticated: MagicMock -): +async def test_password_update(hass: HomeAssistant, service_authenticated: MagicMock): """Test that password reauthentication works successfully.""" config_entry = MockConfigEntry( domain=DOMAIN, data=MOCK_CONFIG, entry_id="test", unique_id=USERNAME @@ -525,7 +521,7 @@ async def test_password_update( assert config_entry.data[CONF_PASSWORD] == PASSWORD_2 -async def test_password_update_wrong_password(hass: HomeAssistantType): +async def test_password_update_wrong_password(hass: HomeAssistant): """Test that during password reauthentication wrong password returns correct error.""" config_entry = MockConfigEntry( domain=DOMAIN, data=MOCK_CONFIG, entry_id="test", unique_id=USERNAME