diff --git a/homeassistant/components/elgato/config_flow.py b/homeassistant/components/elgato/config_flow.py index a8a81734999..2f3e05fd720 100644 --- a/homeassistant/components/elgato/config_flow.py +++ b/homeassistant/components/elgato/config_flow.py @@ -7,8 +7,8 @@ import voluptuous as vol from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, ConfigFlow from homeassistant.const import CONF_HOST, CONF_PORT -from homeassistant.helpers import ConfigType from homeassistant.helpers.aiohttp_client import async_get_clientsession +from homeassistant.helpers.typing import ConfigType from .const import CONF_SERIAL_NUMBER, DOMAIN # pylint: disable=unused-import diff --git a/homeassistant/components/esphome/config_flow.py b/homeassistant/components/esphome/config_flow.py index 1085f734f17..17d3ed5f659 100644 --- a/homeassistant/components/esphome/config_flow.py +++ b/homeassistant/components/esphome/config_flow.py @@ -6,7 +6,7 @@ from aioesphomeapi import APIClient, APIConnectionError import voluptuous as vol from homeassistant import config_entries, core -from homeassistant.helpers import ConfigType +from homeassistant.helpers.typing import ConfigType from .entry_data import DATA_KEY, RuntimeEntryData diff --git a/homeassistant/components/iaqualink/config_flow.py b/homeassistant/components/iaqualink/config_flow.py index d577fe448aa..d64ec711198 100644 --- a/homeassistant/components/iaqualink/config_flow.py +++ b/homeassistant/components/iaqualink/config_flow.py @@ -6,7 +6,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_PASSWORD, CONF_USERNAME -from homeassistant.helpers import ConfigType +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN diff --git a/homeassistant/components/nsw_rural_fire_service_feed/geo_location.py b/homeassistant/components/nsw_rural_fire_service_feed/geo_location.py index a04d2bd69b2..f0d8c901387 100644 --- a/homeassistant/components/nsw_rural_fire_service_feed/geo_location.py +++ b/homeassistant/components/nsw_rural_fire_service_feed/geo_location.py @@ -18,13 +18,13 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_STOP, ) from homeassistant.core import callback -from homeassistant.helpers import ConfigType, aiohttp_client, config_validation as cv +from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, ) from homeassistant.helpers.event import async_track_time_interval -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.helpers.typing import ConfigType, HomeAssistantType _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index a3feccaf10c..3f8bded6a85 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -2,6 +2,7 @@ from datetime import timedelta import functools as ft import logging +from typing import Any, Iterable import voluptuous as vol @@ -19,9 +20,10 @@ 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.loader import bind_hass -# mypy: allow-untyped-defs, no-check-untyped-defs +# mypy: allow-untyped-calls _LOGGER = logging.getLogger(__name__) @@ -57,12 +59,12 @@ REMOTE_SERVICE_ACTIVITY_SCHEMA = make_entity_service_schema( @bind_hass -def is_on(hass, entity_id): +def is_on(hass: HomeAssistantType, entity_id: str) -> bool: """Return if the remote is on based on the statemachine.""" return hass.states.is_state(entity_id, STATE_ON) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Track states and offer events for remotes.""" component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL) await component.async_setup(config) @@ -111,24 +113,26 @@ class RemoteDevice(ToggleEntity): """Representation of a remote.""" @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" return 0 - def send_command(self, command, **kwargs): - """Send a command to a device.""" + def send_command(self, command: Iterable[str], **kwargs: Any) -> None: + """Send commands to a device.""" raise NotImplementedError() - async def async_send_command(self, command, **kwargs): - """Send a command to a device.""" + async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None: + """Send commands to a device.""" + assert self.hass is not None await self.hass.async_add_executor_job( ft.partial(self.send_command, command, **kwargs) ) - def learn_command(self, **kwargs): + def learn_command(self, **kwargs: Any) -> None: """Learn a command from a device.""" raise NotImplementedError() - async def async_learn_command(self, **kwargs): + async def async_learn_command(self, **kwargs: Any) -> None: """Learn a command from a device.""" + assert self.hass is not None await self.hass.async_add_executor_job(ft.partial(self.learn_command, **kwargs)) diff --git a/homeassistant/components/wled/config_flow.py b/homeassistant/components/wled/config_flow.py index 155cd022fd7..dbcd55a7b17 100644 --- a/homeassistant/components/wled/config_flow.py +++ b/homeassistant/components/wled/config_flow.py @@ -11,8 +11,8 @@ from homeassistant.config_entries import ( ConfigFlow, ) from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME -from homeassistant.helpers import ConfigType from homeassistant.helpers.aiohttp_client import async_get_clientsession +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN # pylint: disable=unused-import diff --git a/homeassistant/helpers/__init__.py b/homeassistant/helpers/__init__.py index ad97456968b..7189f519724 100644 --- a/homeassistant/helpers/__init__.py +++ b/homeassistant/helpers/__init__.py @@ -1,10 +1,10 @@ """Helper methods for components within Home Assistant.""" import re -from typing import Any, Dict, Iterable, Sequence, Tuple +from typing import Any, Iterable, Sequence, Tuple from homeassistant.const import CONF_PLATFORM -ConfigType = Dict[str, Any] +from .typing import ConfigType def config_per_platform(config: ConfigType, domain: str) -> Iterable[Tuple[Any, Any]]: