From c1d563873904bd5ab0e25ccd48ddaa488e4923fc Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 30 Mar 2021 01:24:56 +0200 Subject: [PATCH] Remove HomeAssistantType alias from entity components - Part 2 (#48468) --- homeassistant/components/group/__init__.py | 9 ++++----- homeassistant/components/group/light.py | 6 +++--- homeassistant/components/group/reproduce_state.py | 5 ++--- homeassistant/components/history/__init__.py | 5 ++--- homeassistant/components/humidifier/__init__.py | 9 +++++---- homeassistant/components/humidifier/group.py | 5 ++--- .../components/humidifier/reproduce_state.py | 7 +++---- homeassistant/components/input_boolean/__init__.py | 6 +++--- .../components/input_boolean/reproduce_state.py | 7 +++---- homeassistant/components/input_datetime/__init__.py | 6 +++--- .../components/input_datetime/reproduce_state.py | 7 +++---- homeassistant/components/input_number/__init__.py | 6 +++--- .../components/input_number/reproduce_state.py | 7 +++---- homeassistant/components/input_select/__init__.py | 6 +++--- .../components/input_select/reproduce_state.py | 7 +++---- homeassistant/components/input_text/__init__.py | 6 +++--- .../components/input_text/reproduce_state.py | 7 +++---- homeassistant/components/light/__init__.py | 5 ++--- homeassistant/components/light/group.py | 5 ++--- homeassistant/components/light/reproduce_state.py | 7 +++---- homeassistant/components/mqtt/light/__init__.py | 5 +++-- homeassistant/components/notify/__init__.py | 13 ++++++------- homeassistant/components/sensor/group.py | 5 ++--- homeassistant/components/switch/group.py | 5 ++--- homeassistant/components/switch/light.py | 10 +++------- homeassistant/components/switch/reproduce_state.py | 7 +++---- homeassistant/components/weather/group.py | 5 ++--- 27 files changed, 79 insertions(+), 99 deletions(-) diff --git a/homeassistant/components/group/__init__.py b/homeassistant/components/group/__init__.py index 5e8a2e679f6..5af53768bc0 100644 --- a/homeassistant/components/group/__init__.py +++ b/homeassistant/components/group/__init__.py @@ -25,7 +25,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) -from homeassistant.core import CoreState, callback, split_entity_id +from homeassistant.core import CoreState, HomeAssistant, callback, split_entity_id import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity, async_generate_entity_id from homeassistant.helpers.entity_component import EntityComponent @@ -34,7 +34,6 @@ from homeassistant.helpers.integration_platform import ( async_process_integration_platforms, ) from homeassistant.helpers.reload import async_reload_integration_platforms -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.loader import bind_hass # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs @@ -130,7 +129,7 @@ def is_on(hass, entity_id): @bind_hass -def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> list[str]: +def expand_entity_ids(hass: HomeAssistant, entity_ids: Iterable[Any]) -> list[str]: """Return entity_ids with group entity ids replaced by their members. Async friendly. @@ -173,7 +172,7 @@ def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> lis @bind_hass def get_entity_ids( - hass: HomeAssistantType, entity_id: str, domain_filter: str | None = None + hass: HomeAssistant, entity_id: str, domain_filter: str | None = None ) -> list[str]: """Get members of this group. @@ -194,7 +193,7 @@ def get_entity_ids( @bind_hass -def groups_with_entity(hass: HomeAssistantType, entity_id: str) -> list[str]: +def groups_with_entity(hass: HomeAssistant, entity_id: str) -> list[str]: """Get all groups that contain this entity. Async friendly. diff --git a/homeassistant/components/group/light.py b/homeassistant/components/group/light.py index a1cf47411fc..b45dd1ec5e3 100644 --- a/homeassistant/components/group/light.py +++ b/homeassistant/components/group/light.py @@ -37,10 +37,10 @@ from homeassistant.const import ( STATE_ON, STATE_UNAVAILABLE, ) -from homeassistant.core import CoreState, State +from homeassistant.core import CoreState, HomeAssistant, State import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import async_track_state_change_event -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from homeassistant.util import color as color_util from . import GroupEntity @@ -69,7 +69,7 @@ SUPPORT_GROUP_LIGHT = ( async def async_setup_platform( - hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None + hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None ) -> None: """Initialize light.group platform.""" async_add_entities( diff --git a/homeassistant/components/group/reproduce_state.py b/homeassistant/components/group/reproduce_state.py index f91b1e119af..ea21c147b9b 100644 --- a/homeassistant/components/group/reproduce_state.py +++ b/homeassistant/components/group/reproduce_state.py @@ -3,15 +3,14 @@ from __future__ import annotations from typing import Any, Iterable -from homeassistant.core import Context, State +from homeassistant.core import Context, HomeAssistant, State from homeassistant.helpers.state import async_reproduce_state -from homeassistant.helpers.typing import HomeAssistantType from . import get_entity_ids async def async_reproduce_states( - hass: HomeAssistantType, + hass: HomeAssistant, states: Iterable[State], *, context: Context | None = None, diff --git a/homeassistant/components/history/__init__.py b/homeassistant/components/history/__init__.py index fbce4909e13..59fdcc7811b 100644 --- a/homeassistant/components/history/__init__.py +++ b/homeassistant/components/history/__init__.py @@ -29,13 +29,12 @@ from homeassistant.const import ( CONF_INCLUDE, HTTP_BAD_REQUEST, ) -from homeassistant.core import Context, State, split_entity_id +from homeassistant.core import Context, HomeAssistant, State, split_entity_id import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entityfilter import ( CONF_ENTITY_GLOBS, INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA, ) -from homeassistant.helpers.typing import HomeAssistantType import homeassistant.util.dt as dt_util # mypy: allow-untyped-defs, no-check-untyped-defs @@ -673,7 +672,7 @@ def _glob_to_like(glob_str): def _entities_may_have_state_changes_after( - hass: HomeAssistantType, entity_ids: Iterable, start_time: dt + hass: HomeAssistant, entity_ids: Iterable, start_time: dt ) -> bool: """Check the state machine to see if entities have changed since start time.""" for entity_id in entity_ids: diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index f6a4ebcccd9..9500b74aba6 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -15,6 +15,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_ON, ) +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import ( # noqa: F401 PLATFORM_SCHEMA, @@ -22,7 +23,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401 ) from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from homeassistant.loader import bind_hass from .const import ( @@ -59,7 +60,7 @@ def is_on(hass, entity_id): return hass.states.is_state(entity_id, STATE_ON) -async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up humidifier devices.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL @@ -88,12 +89,12 @@ 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 a config entry.""" return await hass.data[DOMAIN].async_setup_entry(entry) -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" return await hass.data[DOMAIN].async_unload_entry(entry) diff --git a/homeassistant/components/humidifier/group.py b/homeassistant/components/humidifier/group.py index 1636054663d..234883ffd5a 100644 --- a/homeassistant/components/humidifier/group.py +++ b/homeassistant/components/humidifier/group.py @@ -3,13 +3,12 @@ from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.const import STATE_OFF, STATE_ON -from homeassistant.core import callback -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant, callback @callback def async_describe_on_off_states( - hass: HomeAssistantType, registry: GroupIntegrationRegistry + hass: HomeAssistant, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states({STATE_ON}, STATE_OFF) diff --git a/homeassistant/components/humidifier/reproduce_state.py b/homeassistant/components/humidifier/reproduce_state.py index b20edacec46..3f73ebf4e0a 100644 --- a/homeassistant/components/humidifier/reproduce_state.py +++ b/homeassistant/components/humidifier/reproduce_state.py @@ -12,8 +12,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) -from homeassistant.core import Context, State -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import Context, HomeAssistant, State from .const import ATTR_HUMIDITY, DOMAIN, SERVICE_SET_HUMIDITY, SERVICE_SET_MODE @@ -21,7 +20,7 @@ _LOGGER = logging.getLogger(__name__) async def _async_reproduce_states( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -81,7 +80,7 @@ async def _async_reproduce_states( async def async_reproduce_states( - hass: HomeAssistantType, + hass: HomeAssistant, states: Iterable[State], *, context: Context | None = None, diff --git a/homeassistant/components/input_boolean/__init__.py b/homeassistant/components/input_boolean/__init__.py index b46135d934a..e030a530253 100644 --- a/homeassistant/components/input_boolean/__init__.py +++ b/homeassistant/components/input_boolean/__init__.py @@ -16,7 +16,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_ON, ) -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 import ToggleEntity @@ -24,7 +24,7 @@ from homeassistant.helpers.entity_component import EntityComponent 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 from homeassistant.loader import bind_hass DOMAIN = "input_boolean" @@ -82,7 +82,7 @@ def is_on(hass, entity_id): return hass.states.is_state(entity_id, STATE_ON) -async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up an input boolean.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() diff --git a/homeassistant/components/input_boolean/reproduce_state.py b/homeassistant/components/input_boolean/reproduce_state.py index 8e8edcfd11b..5fe7e779a98 100644 --- a/homeassistant/components/input_boolean/reproduce_state.py +++ b/homeassistant/components/input_boolean/reproduce_state.py @@ -12,8 +12,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) -from homeassistant.core import Context, State -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import Context, HomeAssistant, State from . import DOMAIN @@ -21,7 +20,7 @@ _LOGGER = logging.getLogger(__name__) async def _async_reproduce_states( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -55,7 +54,7 @@ async def _async_reproduce_states( async def async_reproduce_states( - hass: HomeAssistantType, + hass: HomeAssistant, states: Iterable[State], *, context: Context | None = None, diff --git a/homeassistant/components/input_datetime/__init__.py b/homeassistant/components/input_datetime/__init__.py index c408c73f869..68b7f9f32d5 100644 --- a/homeassistant/components/input_datetime/__init__.py +++ b/homeassistant/components/input_datetime/__init__.py @@ -15,14 +15,14 @@ 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 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 from homeassistant.util import dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -101,7 +101,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 datetime.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() diff --git a/homeassistant/components/input_datetime/reproduce_state.py b/homeassistant/components/input_datetime/reproduce_state.py index a537a921f39..f996721eabd 100644 --- a/homeassistant/components/input_datetime/reproduce_state.py +++ b/homeassistant/components/input_datetime/reproduce_state.py @@ -6,8 +6,7 @@ import logging from typing import Any, Iterable 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 homeassistant.util import dt as dt_util from . import ATTR_DATE, ATTR_DATETIME, ATTR_TIME, CONF_HAS_DATE, CONF_HAS_TIME, DOMAIN @@ -34,7 +33,7 @@ def is_valid_time(string: str) -> bool: async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -79,7 +78,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/input_number/__init__.py b/homeassistant/components/input_number/__init__.py index d22a43c3330..a895326c677 100644 --- a/homeassistant/components/input_number/__init__.py +++ b/homeassistant/components/input_number/__init__.py @@ -15,14 +15,14 @@ from homeassistant.const import ( CONF_UNIT_OF_MEASUREMENT, 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 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 _LOGGER = logging.getLogger(__name__) @@ -112,7 +112,7 @@ STORAGE_KEY = DOMAIN STORAGE_VERSION = 1 -async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up an input slider.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() diff --git a/homeassistant/components/input_number/reproduce_state.py b/homeassistant/components/input_number/reproduce_state.py index 1f9af63e01b..a897aec2ba8 100644 --- a/homeassistant/components/input_number/reproduce_state.py +++ b/homeassistant/components/input_number/reproduce_state.py @@ -8,8 +8,7 @@ from typing import Any, Iterable import voluptuous as vol 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_VALUE, DOMAIN, SERVICE_SET_VALUE @@ -17,7 +16,7 @@ _LOGGER = logging.getLogger(__name__) async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -55,7 +54,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/input_select/__init__.py b/homeassistant/components/input_select/__init__.py index 92defe2ded9..374254a5052 100644 --- a/homeassistant/components/input_select/__init__.py +++ b/homeassistant/components/input_select/__init__.py @@ -13,14 +13,14 @@ 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 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 _LOGGER = logging.getLogger(__name__) @@ -87,7 +87,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/input_select/reproduce_state.py b/homeassistant/components/input_select/reproduce_state.py index beaee109750..5ea7072e932 100644 --- a/homeassistant/components/input_select/reproduce_state.py +++ b/homeassistant/components/input_select/reproduce_state.py @@ -7,8 +7,7 @@ from types import MappingProxyType from typing import Any, Iterable 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_OPTION, @@ -24,7 +23,7 @@ _LOGGER = logging.getLogger(__name__) async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -70,7 +69,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/input_text/__init__.py b/homeassistant/components/input_text/__init__.py index 3eef18f01b1..2f9f6cb47ba 100644 --- a/homeassistant/components/input_text/__init__.py +++ b/homeassistant/components/input_text/__init__.py @@ -15,14 +15,14 @@ from homeassistant.const import ( CONF_UNIT_OF_MEASUREMENT, 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 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 _LOGGER = logging.getLogger(__name__) @@ -112,7 +112,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 text.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() diff --git a/homeassistant/components/input_text/reproduce_state.py b/homeassistant/components/input_text/reproduce_state.py index 62e1a1fbd68..ce1b7c12c46 100644 --- a/homeassistant/components/input_text/reproduce_state.py +++ b/homeassistant/components/input_text/reproduce_state.py @@ -6,8 +6,7 @@ import logging from typing import Any, Iterable 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_VALUE, DOMAIN, SERVICE_SET_VALUE @@ -15,7 +14,7 @@ _LOGGER = logging.getLogger(__name__) async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -43,7 +42,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/light/__init__.py b/homeassistant/components/light/__init__.py index 06b6829d31c..4fae5caab00 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -16,7 +16,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_ON, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import ( # noqa: F401 PLATFORM_SCHEMA, @@ -25,7 +25,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401 ) from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.loader import bind_hass import homeassistant.util.color as color_util @@ -411,7 +410,7 @@ class Profile: class Profiles: """Representation of available color profiles.""" - def __init__(self, hass: HomeAssistantType): + def __init__(self, hass: HomeAssistant): """Initialize profiles.""" self.hass = hass self.data: dict[str, Profile] = {} diff --git a/homeassistant/components/light/group.py b/homeassistant/components/light/group.py index 1636054663d..234883ffd5a 100644 --- a/homeassistant/components/light/group.py +++ b/homeassistant/components/light/group.py @@ -3,13 +3,12 @@ from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.const import STATE_OFF, STATE_ON -from homeassistant.core import callback -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant, callback @callback def async_describe_on_off_states( - hass: HomeAssistantType, registry: GroupIntegrationRegistry + hass: HomeAssistant, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states({STATE_ON}, STATE_OFF) diff --git a/homeassistant/components/light/reproduce_state.py b/homeassistant/components/light/reproduce_state.py index 13a014426a0..68fac8aa5c9 100644 --- a/homeassistant/components/light/reproduce_state.py +++ b/homeassistant/components/light/reproduce_state.py @@ -13,8 +13,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) -from homeassistant.core import Context, State -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import Context, HomeAssistant, State from . import ( ATTR_BRIGHTNESS, @@ -94,7 +93,7 @@ DEPRECATION_WARNING = ( async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -170,7 +169,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/mqtt/light/__init__.py b/homeassistant/components/mqtt/light/__init__.py index 412302273ac..95a0cde52f4 100644 --- a/homeassistant/components/mqtt/light/__init__.py +++ b/homeassistant/components/mqtt/light/__init__.py @@ -4,8 +4,9 @@ import functools import voluptuous as vol from homeassistant.components import light +from homeassistant.core import HomeAssistant from homeassistant.helpers.reload import async_setup_reload_service -from homeassistant.helpers.typing import ConfigType, HomeAssistantType +from homeassistant.helpers.typing import ConfigType from .. import DOMAIN, PLATFORMS from ..mixins import async_setup_entry_helper @@ -31,7 +32,7 @@ PLATFORM_SCHEMA = vol.All( async def async_setup_platform( - hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None + hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None ): """Set up MQTT light through configuration.yaml.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) diff --git a/homeassistant/components/notify/__init__.py b/homeassistant/components/notify/__init__.py index f85f07a0bd5..8f89c108440 100644 --- a/homeassistant/components/notify/__init__.py +++ b/homeassistant/components/notify/__init__.py @@ -10,12 +10,11 @@ import voluptuous as vol import homeassistant.components.persistent_notification as pn from homeassistant.const import CONF_NAME, CONF_PLATFORM -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_per_platform, discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.service import async_set_service_schema -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.loader import async_get_integration, bind_hass from homeassistant.setup import async_prepare_setup_platform from homeassistant.util import slugify @@ -71,7 +70,7 @@ PERSISTENT_NOTIFICATION_SERVICE_SCHEMA = vol.Schema( @bind_hass -async def async_reload(hass: HomeAssistantType, integration_name: str) -> None: +async def async_reload(hass: HomeAssistant, integration_name: str) -> None: """Register notify services for an integration.""" if not _async_integration_has_notify_services(hass, integration_name): return @@ -85,7 +84,7 @@ async def async_reload(hass: HomeAssistantType, integration_name: str) -> None: @bind_hass -async def async_reset_platform(hass: HomeAssistantType, integration_name: str) -> None: +async def async_reset_platform(hass: HomeAssistant, integration_name: str) -> None: """Unregister notify services for an integration.""" if not _async_integration_has_notify_services(hass, integration_name): return @@ -101,7 +100,7 @@ async def async_reset_platform(hass: HomeAssistantType, integration_name: str) - def _async_integration_has_notify_services( - hass: HomeAssistantType, integration_name: str + hass: HomeAssistant, integration_name: str ) -> bool: """Determine if an integration has notify services registered.""" if ( @@ -119,7 +118,7 @@ class BaseNotificationService: # While not purely typed, it makes typehinting more useful for us # and removes the need for constant None checks or asserts. # Ignore types: https://github.com/PyCQA/pylint/issues/3167 - hass: HomeAssistantType = None # type: ignore + hass: HomeAssistant = None # type: ignore # Name => target registered_targets: dict[str, str] @@ -163,7 +162,7 @@ class BaseNotificationService: async def async_setup( self, - hass: HomeAssistantType, + hass: HomeAssistant, service_name: str, target_service_name_prefix: str, ) -> None: diff --git a/homeassistant/components/sensor/group.py b/homeassistant/components/sensor/group.py index 4741f8a3b54..2ac081496cd 100644 --- a/homeassistant/components/sensor/group.py +++ b/homeassistant/components/sensor/group.py @@ -2,13 +2,12 @@ from homeassistant.components.group import GroupIntegrationRegistry -from homeassistant.core import callback -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant, callback @callback def async_describe_on_off_states( - hass: HomeAssistantType, registry: GroupIntegrationRegistry + hass: HomeAssistant, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.exclude_domain() diff --git a/homeassistant/components/switch/group.py b/homeassistant/components/switch/group.py index 1636054663d..234883ffd5a 100644 --- a/homeassistant/components/switch/group.py +++ b/homeassistant/components/switch/group.py @@ -3,13 +3,12 @@ from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.const import STATE_OFF, STATE_ON -from homeassistant.core import callback -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant, callback @callback def async_describe_on_off_states( - hass: HomeAssistantType, registry: GroupIntegrationRegistry + hass: HomeAssistant, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states({STATE_ON}, STATE_OFF) diff --git a/homeassistant/components/switch/light.py b/homeassistant/components/switch/light.py index 4ab030bc8e4..e2154810522 100644 --- a/homeassistant/components/switch/light.py +++ b/homeassistant/components/switch/light.py @@ -14,15 +14,11 @@ from homeassistant.const import ( STATE_ON, STATE_UNAVAILABLE, ) -from homeassistant.core import State, callback +from homeassistant.core import HomeAssistant, State, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_state_change_event -from homeassistant.helpers.typing import ( - ConfigType, - DiscoveryInfoType, - HomeAssistantType, -) +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs @@ -37,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( async def async_setup_platform( - hass: HomeAssistantType, + hass: HomeAssistant, config: ConfigType, async_add_entities: Callable[[Sequence[Entity]], None], discovery_info: DiscoveryInfoType | None = None, diff --git a/homeassistant/components/switch/reproduce_state.py b/homeassistant/components/switch/reproduce_state.py index 5a90af4181c..94fd836631b 100644 --- a/homeassistant/components/switch/reproduce_state.py +++ b/homeassistant/components/switch/reproduce_state.py @@ -12,8 +12,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) -from homeassistant.core import Context, State -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import Context, HomeAssistant, State from . import DOMAIN @@ -23,7 +22,7 @@ VALID_STATES = {STATE_ON, STATE_OFF} async def _async_reproduce_state( - hass: HomeAssistantType, + hass: HomeAssistant, state: State, *, context: Context | None = None, @@ -59,7 +58,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/weather/group.py b/homeassistant/components/weather/group.py index 4741f8a3b54..2ac081496cd 100644 --- a/homeassistant/components/weather/group.py +++ b/homeassistant/components/weather/group.py @@ -2,13 +2,12 @@ from homeassistant.components.group import GroupIntegrationRegistry -from homeassistant.core import callback -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant, callback @callback def async_describe_on_off_states( - hass: HomeAssistantType, registry: GroupIntegrationRegistry + hass: HomeAssistant, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.exclude_domain()