Remove HomeAssistantType alias from entity components - Part 2 (#48468)

This commit is contained in:
Franck Nijhof 2021-03-30 01:24:56 +02:00 committed by GitHub
parent 855b68faa1
commit c1d5638739
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 79 additions and 99 deletions

View file

@ -25,7 +25,7 @@ from homeassistant.const import (
STATE_OFF, STATE_OFF,
STATE_ON, 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 import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity, async_generate_entity_id from homeassistant.helpers.entity import Entity, async_generate_entity_id
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
@ -34,7 +34,6 @@ from homeassistant.helpers.integration_platform import (
async_process_integration_platforms, async_process_integration_platforms,
) )
from homeassistant.helpers.reload import async_reload_integration_platforms from homeassistant.helpers.reload import async_reload_integration_platforms
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
@ -130,7 +129,7 @@ def is_on(hass, entity_id):
@bind_hass @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. """Return entity_ids with group entity ids replaced by their members.
Async friendly. Async friendly.
@ -173,7 +172,7 @@ def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> lis
@bind_hass @bind_hass
def get_entity_ids( 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]: ) -> list[str]:
"""Get members of this group. """Get members of this group.
@ -194,7 +193,7 @@ def get_entity_ids(
@bind_hass @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. """Get all groups that contain this entity.
Async friendly. Async friendly.

View file

@ -37,10 +37,10 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
) )
from homeassistant.core import CoreState, State from homeassistant.core import CoreState, HomeAssistant, State
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_state_change_event 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 homeassistant.util import color as color_util
from . import GroupEntity from . import GroupEntity
@ -69,7 +69,7 @@ SUPPORT_GROUP_LIGHT = (
async def async_setup_platform( 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: ) -> None:
"""Initialize light.group platform.""" """Initialize light.group platform."""
async_add_entities( async_add_entities(

View file

@ -3,15 +3,14 @@ from __future__ import annotations
from typing import Any, Iterable 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.state import async_reproduce_state
from homeassistant.helpers.typing import HomeAssistantType
from . import get_entity_ids from . import get_entity_ids
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -29,13 +29,12 @@ from homeassistant.const import (
CONF_INCLUDE, CONF_INCLUDE,
HTTP_BAD_REQUEST, 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 import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import ( from homeassistant.helpers.entityfilter import (
CONF_ENTITY_GLOBS, CONF_ENTITY_GLOBS,
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA, INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
) )
from homeassistant.helpers.typing import HomeAssistantType
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
# mypy: allow-untyped-defs, no-check-untyped-defs # 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( def _entities_may_have_state_changes_after(
hass: HomeAssistantType, entity_ids: Iterable, start_time: dt hass: HomeAssistant, entity_ids: Iterable, start_time: dt
) -> bool: ) -> bool:
"""Check the state machine to see if entities have changed since start time.""" """Check the state machine to see if entities have changed since start time."""
for entity_id in entity_ids: for entity_id in entity_ids:

View file

@ -15,6 +15,7 @@ from homeassistant.const import (
SERVICE_TURN_ON, SERVICE_TURN_ON,
STATE_ON, STATE_ON,
) )
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa: F401 from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
@ -22,7 +23,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
) )
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent 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 homeassistant.loader import bind_hass
from .const import ( from .const import (
@ -59,7 +60,7 @@ def is_on(hass, entity_id):
return hass.states.is_state(entity_id, STATE_ON) 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.""" """Set up humidifier devices."""
component = hass.data[DOMAIN] = EntityComponent( component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL _LOGGER, DOMAIN, hass, SCAN_INTERVAL
@ -88,12 +89,12 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
return True 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.""" """Set up a config entry."""
return await hass.data[DOMAIN].async_setup_entry(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.""" """Unload a config entry."""
return await hass.data[DOMAIN].async_unload_entry(entry) return await hass.data[DOMAIN].async_unload_entry(entry)

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import HomeAssistantType
@callback @callback
def async_describe_on_off_states( def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None: ) -> None:
"""Describe group on off states.""" """Describe group on off states."""
registry.on_off_states({STATE_ON}, STATE_OFF) registry.on_off_states({STATE_ON}, STATE_OFF)

View file

@ -12,8 +12,7 @@ from homeassistant.const import (
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
) )
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from .const import ATTR_HUMIDITY, DOMAIN, SERVICE_SET_HUMIDITY, SERVICE_SET_MODE 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( async def _async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -81,7 +80,7 @@ async def _async_reproduce_states(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -16,7 +16,7 @@ from homeassistant.const import (
SERVICE_TURN_ON, SERVICE_TURN_ON,
STATE_ON, STATE_ON,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import collection from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
@ -24,7 +24,7 @@ from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service import homeassistant.helpers.service
from homeassistant.helpers.storage import Store 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 from homeassistant.loader import bind_hass
DOMAIN = "input_boolean" DOMAIN = "input_boolean"
@ -82,7 +82,7 @@ def is_on(hass, entity_id):
return hass.states.is_state(entity_id, STATE_ON) 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.""" """Set up an input boolean."""
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager() id_manager = collection.IDManager()

View file

@ -12,8 +12,7 @@ from homeassistant.const import (
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
) )
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from . import DOMAIN from . import DOMAIN
@ -21,7 +20,7 @@ _LOGGER = logging.getLogger(__name__)
async def _async_reproduce_states( async def _async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -55,7 +54,7 @@ async def _async_reproduce_states(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -15,14 +15,14 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
SERVICE_RELOAD, SERVICE_RELOAD,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import collection from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service import homeassistant.helpers.service
from homeassistant.helpers.storage import Store 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 from homeassistant.util import dt as dt_util
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -101,7 +101,7 @@ CONFIG_SCHEMA = vol.Schema(
RELOAD_SERVICE_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.""" """Set up an input datetime."""
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager() id_manager = collection.IDManager()

View file

@ -6,8 +6,7 @@ import logging
from typing import Any, Iterable from typing import Any, Iterable
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from . import ATTR_DATE, ATTR_DATETIME, ATTR_TIME, CONF_HAS_DATE, CONF_HAS_TIME, DOMAIN 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( async def _async_reproduce_state(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -79,7 +78,7 @@ async def _async_reproduce_state(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -15,14 +15,14 @@ from homeassistant.const import (
CONF_UNIT_OF_MEASUREMENT, CONF_UNIT_OF_MEASUREMENT,
SERVICE_RELOAD, SERVICE_RELOAD,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import collection from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service import homeassistant.helpers.service
from homeassistant.helpers.storage import Store 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__) _LOGGER = logging.getLogger(__name__)
@ -112,7 +112,7 @@ STORAGE_KEY = DOMAIN
STORAGE_VERSION = 1 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.""" """Set up an input slider."""
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager() id_manager = collection.IDManager()

View file

@ -8,8 +8,7 @@ from typing import Any, Iterable
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from . import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE from . import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE
@ -17,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
async def _async_reproduce_state( async def _async_reproduce_state(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -55,7 +54,7 @@ async def _async_reproduce_state(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -13,14 +13,14 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
SERVICE_RELOAD, SERVICE_RELOAD,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import collection from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service import homeassistant.helpers.service
from homeassistant.helpers.storage import Store 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__) _LOGGER = logging.getLogger(__name__)
@ -87,7 +87,7 @@ CONFIG_SCHEMA = vol.Schema(
RELOAD_SERVICE_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.""" """Set up an input select."""
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager() id_manager = collection.IDManager()

View file

@ -7,8 +7,7 @@ from types import MappingProxyType
from typing import Any, Iterable from typing import Any, Iterable
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from . import ( from . import (
ATTR_OPTION, ATTR_OPTION,
@ -24,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
async def _async_reproduce_state( async def _async_reproduce_state(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -70,7 +69,7 @@ async def _async_reproduce_state(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -15,14 +15,14 @@ from homeassistant.const import (
CONF_UNIT_OF_MEASUREMENT, CONF_UNIT_OF_MEASUREMENT,
SERVICE_RELOAD, SERVICE_RELOAD,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import collection from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service import homeassistant.helpers.service
from homeassistant.helpers.storage import Store 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__) _LOGGER = logging.getLogger(__name__)
@ -112,7 +112,7 @@ CONFIG_SCHEMA = vol.Schema(
RELOAD_SERVICE_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.""" """Set up an input text."""
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager() id_manager = collection.IDManager()

View file

@ -6,8 +6,7 @@ import logging
from typing import Any, Iterable from typing import Any, Iterable
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from . import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE from . import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE
@ -15,7 +14,7 @@ _LOGGER = logging.getLogger(__name__)
async def _async_reproduce_state( async def _async_reproduce_state(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -43,7 +42,7 @@ async def _async_reproduce_state(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -16,7 +16,7 @@ from homeassistant.const import (
SERVICE_TURN_ON, SERVICE_TURN_ON,
STATE_ON, STATE_ON,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa: F401 from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
@ -25,7 +25,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
) )
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -411,7 +410,7 @@ class Profile:
class Profiles: class Profiles:
"""Representation of available color profiles.""" """Representation of available color profiles."""
def __init__(self, hass: HomeAssistantType): def __init__(self, hass: HomeAssistant):
"""Initialize profiles.""" """Initialize profiles."""
self.hass = hass self.hass = hass
self.data: dict[str, Profile] = {} self.data: dict[str, Profile] = {}

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import HomeAssistantType
@callback @callback
def async_describe_on_off_states( def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None: ) -> None:
"""Describe group on off states.""" """Describe group on off states."""
registry.on_off_states({STATE_ON}, STATE_OFF) registry.on_off_states({STATE_ON}, STATE_OFF)

View file

@ -13,8 +13,7 @@ from homeassistant.const import (
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
) )
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from . import ( from . import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
@ -94,7 +93,7 @@ DEPRECATION_WARNING = (
async def _async_reproduce_state( async def _async_reproduce_state(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -170,7 +169,7 @@ async def _async_reproduce_state(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -4,8 +4,9 @@ import functools
import voluptuous as vol import voluptuous as vol
from homeassistant.components import light from homeassistant.components import light
from homeassistant.core import HomeAssistant
from homeassistant.helpers.reload import async_setup_reload_service 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 .. import DOMAIN, PLATFORMS
from ..mixins import async_setup_entry_helper from ..mixins import async_setup_entry_helper
@ -31,7 +32,7 @@ PLATFORM_SCHEMA = vol.All(
async def async_setup_platform( 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.""" """Set up MQTT light through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View file

@ -10,12 +10,11 @@ import voluptuous as vol
import homeassistant.components.persistent_notification as pn import homeassistant.components.persistent_notification as pn
from homeassistant.const import CONF_NAME, CONF_PLATFORM 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.exceptions import HomeAssistantError
from homeassistant.helpers import config_per_platform, discovery from homeassistant.helpers import config_per_platform, discovery
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.service import async_set_service_schema 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.loader import async_get_integration, bind_hass
from homeassistant.setup import async_prepare_setup_platform from homeassistant.setup import async_prepare_setup_platform
from homeassistant.util import slugify from homeassistant.util import slugify
@ -71,7 +70,7 @@ PERSISTENT_NOTIFICATION_SERVICE_SCHEMA = vol.Schema(
@bind_hass @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.""" """Register notify services for an integration."""
if not _async_integration_has_notify_services(hass, integration_name): if not _async_integration_has_notify_services(hass, integration_name):
return return
@ -85,7 +84,7 @@ async def async_reload(hass: HomeAssistantType, integration_name: str) -> None:
@bind_hass @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.""" """Unregister notify services for an integration."""
if not _async_integration_has_notify_services(hass, integration_name): if not _async_integration_has_notify_services(hass, integration_name):
return return
@ -101,7 +100,7 @@ async def async_reset_platform(hass: HomeAssistantType, integration_name: str) -
def _async_integration_has_notify_services( def _async_integration_has_notify_services(
hass: HomeAssistantType, integration_name: str hass: HomeAssistant, integration_name: str
) -> bool: ) -> bool:
"""Determine if an integration has notify services registered.""" """Determine if an integration has notify services registered."""
if ( if (
@ -119,7 +118,7 @@ class BaseNotificationService:
# While not purely typed, it makes typehinting more useful for us # While not purely typed, it makes typehinting more useful for us
# and removes the need for constant None checks or asserts. # and removes the need for constant None checks or asserts.
# Ignore types: https://github.com/PyCQA/pylint/issues/3167 # Ignore types: https://github.com/PyCQA/pylint/issues/3167
hass: HomeAssistantType = None # type: ignore hass: HomeAssistant = None # type: ignore
# Name => target # Name => target
registered_targets: dict[str, str] registered_targets: dict[str, str]
@ -163,7 +162,7 @@ class BaseNotificationService:
async def async_setup( async def async_setup(
self, self,
hass: HomeAssistantType, hass: HomeAssistant,
service_name: str, service_name: str,
target_service_name_prefix: str, target_service_name_prefix: str,
) -> None: ) -> None:

View file

@ -2,13 +2,12 @@
from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import HomeAssistantType
@callback @callback
def async_describe_on_off_states( def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None: ) -> None:
"""Describe group on off states.""" """Describe group on off states."""
registry.exclude_domain() registry.exclude_domain()

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import HomeAssistantType
@callback @callback
def async_describe_on_off_states( def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None: ) -> None:
"""Describe group on off states.""" """Describe group on off states."""
registry.on_off_states({STATE_ON}, STATE_OFF) registry.on_off_states({STATE_ON}, STATE_OFF)

View file

@ -14,15 +14,11 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
) )
from homeassistant.core import State, callback from homeassistant.core import HomeAssistant, State, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.typing import ( from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs # 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( async def async_setup_platform(
hass: HomeAssistantType, hass: HomeAssistant,
config: ConfigType, config: ConfigType,
async_add_entities: Callable[[Sequence[Entity]], None], async_add_entities: Callable[[Sequence[Entity]], None],
discovery_info: DiscoveryInfoType | None = None, discovery_info: DiscoveryInfoType | None = None,

View file

@ -12,8 +12,7 @@ from homeassistant.const import (
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
) )
from homeassistant.core import Context, State from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.typing import HomeAssistantType
from . import DOMAIN from . import DOMAIN
@ -23,7 +22,7 @@ VALID_STATES = {STATE_ON, STATE_OFF}
async def _async_reproduce_state( async def _async_reproduce_state(
hass: HomeAssistantType, hass: HomeAssistant,
state: State, state: State,
*, *,
context: Context | None = None, context: Context | None = None,
@ -59,7 +58,7 @@ async def _async_reproduce_state(
async def async_reproduce_states( async def async_reproduce_states(
hass: HomeAssistantType, hass: HomeAssistant,
states: Iterable[State], states: Iterable[State],
*, *,
context: Context | None = None, context: Context | None = None,

View file

@ -2,13 +2,12 @@
from homeassistant.components.group import GroupIntegrationRegistry from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import HomeAssistantType
@callback @callback
def async_describe_on_off_states( def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None: ) -> None:
"""Describe group on off states.""" """Describe group on off states."""
registry.exclude_domain() registry.exclude_domain()