From 04e8e84058fc4438efea9bc6fa31d1a9a9362f41 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 31 Dec 2021 11:05:44 +0100 Subject: [PATCH] Add init type hints [e] (#63102) Co-authored-by: epenet --- homeassistant/components/eafm/__init__.py | 7 ++++--- homeassistant/components/ebusd/__init__.py | 5 +++-- homeassistant/components/ecoal_boiler/__init__.py | 4 +++- homeassistant/components/ecobee/__init__.py | 10 ++++++---- homeassistant/components/econet/__init__.py | 10 ++++++---- homeassistant/components/ecovacs/__init__.py | 4 +++- homeassistant/components/egardia/__init__.py | 4 +++- homeassistant/components/elv/__init__.py | 4 +++- .../components/emoncms_history/__init__.py | 4 +++- homeassistant/components/emulated_hue/__init__.py | 4 +++- homeassistant/components/emulated_roku/__init__.py | 9 ++++++--- homeassistant/components/enocean/__init__.py | 14 ++++++-------- .../components/environment_canada/__init__.py | 6 ++++-- homeassistant/components/eufy/__init__.py | 4 +++- 14 files changed, 56 insertions(+), 33 deletions(-) diff --git a/homeassistant/components/eafm/__init__.py b/homeassistant/components/eafm/__init__.py index 513db3a7bed..e7b6cd88092 100644 --- a/homeassistant/components/eafm/__init__.py +++ b/homeassistant/components/eafm/__init__.py @@ -1,19 +1,20 @@ """UK Environment Agency Flood Monitoring Integration.""" - +from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform +from homeassistant.core import HomeAssistant from .const import DOMAIN PLATFORMS = [Platform.SENSOR] -async def async_setup_entry(hass, entry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up flood monitoring sensors for this config entry.""" hass.data.setdefault(DOMAIN, {}) hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload flood monitoring sensors.""" return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/ebusd/__init__.py b/homeassistant/components/ebusd/__init__.py index df099b20f18..5a8864fd56e 100644 --- a/homeassistant/components/ebusd/__init__.py +++ b/homeassistant/components/ebusd/__init__.py @@ -11,9 +11,10 @@ from homeassistant.const import ( CONF_NAME, CONF_PORT, ) -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import load_platform +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, SENSOR_TYPES @@ -54,7 +55,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the eBusd component.""" _LOGGER.debug("Integration setup started") conf = config[DOMAIN] diff --git a/homeassistant/components/ecoal_boiler/__init__.py b/homeassistant/components/ecoal_boiler/__init__.py index b0ca7aec5cc..00bc6bf3956 100644 --- a/homeassistant/components/ecoal_boiler/__init__.py +++ b/homeassistant/components/ecoal_boiler/__init__.py @@ -12,8 +12,10 @@ from homeassistant.const import ( CONF_SWITCHES, CONF_USERNAME, ) +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import load_platform +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -79,7 +81,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, hass_config): +def setup(hass: HomeAssistant, hass_config: ConfigType) -> bool: """Set up global ECoalController instance same for sensors and switches.""" conf = hass_config[DOMAIN] diff --git a/homeassistant/components/ecobee/__init__.py b/homeassistant/components/ecobee/__init__.py index 28aec51e81f..ceab670fa6e 100644 --- a/homeassistant/components/ecobee/__init__.py +++ b/homeassistant/components/ecobee/__init__.py @@ -4,9 +4,11 @@ from datetime import timedelta from pyecobee import ECOBEE_API_KEY, ECOBEE_REFRESH_TOKEN, Ecobee, ExpiredTokenError import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import CONF_API_KEY +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType from homeassistant.util import Throttle from .const import _LOGGER, CONF_REFRESH_TOKEN, DATA_ECOBEE_CONFIG, DOMAIN, PLATFORMS @@ -18,7 +20,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """ Ecobee uses config flow for configuration. @@ -41,7 +43,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass, entry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up ecobee via a config entry.""" api_key = entry.data[CONF_API_KEY] refresh_token = entry.data[CONF_REFRESH_TOKEN] @@ -105,7 +107,7 @@ class EcobeeData: return False -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload the config entry and platforms.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: diff --git a/homeassistant/components/econet/__init__.py b/homeassistant/components/econet/__init__.py index c3abea82d7f..100b58b107d 100644 --- a/homeassistant/components/econet/__init__.py +++ b/homeassistant/components/econet/__init__.py @@ -12,12 +12,14 @@ from pyeconet.errors import ( PyeconetError, ) +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, TEMP_FAHRENHEIT, Platform -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.dispatcher import dispatcher_send from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType from .const import API_CLIENT, DOMAIN, EQUIPMENT @@ -34,7 +36,7 @@ PUSH_UPDATE = "econet.push_update" INTERVAL = timedelta(minutes=60) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the EcoNet component.""" hass.data[DOMAIN] = {} hass.data[DOMAIN][API_CLIENT] = {} @@ -42,7 +44,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up EcoNet as config entry.""" email = config_entry.data[CONF_EMAIL] @@ -97,7 +99,7 @@ async def async_setup_entry(hass, config_entry): return True -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a EcoNet config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: diff --git a/homeassistant/components/ecovacs/__init__.py b/homeassistant/components/ecovacs/__init__.py index 8a6475c0192..c50cfdb02c1 100644 --- a/homeassistant/components/ecovacs/__init__.py +++ b/homeassistant/components/ecovacs/__init__.py @@ -7,8 +7,10 @@ from sucks import EcoVacsAPI, VacBot import voluptuous as vol from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP +from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -39,7 +41,7 @@ ECOVACS_API_DEVICEID = "".join( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Ecovacs component.""" _LOGGER.debug("Creating new Ecovacs component") diff --git a/homeassistant/components/egardia/__init__.py b/homeassistant/components/egardia/__init__.py index 8b67d23d3cc..7fd17e61c6f 100644 --- a/homeassistant/components/egardia/__init__.py +++ b/homeassistant/components/egardia/__init__.py @@ -13,8 +13,10 @@ from homeassistant.const import ( CONF_USERNAME, EVENT_HOMEASSISTANT_STOP, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -77,7 +79,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Egardia platform.""" conf = config[DOMAIN] diff --git a/homeassistant/components/elv/__init__.py b/homeassistant/components/elv/__init__.py index a9076fc1d2f..7e5b8a322a5 100644 --- a/homeassistant/components/elv/__init__.py +++ b/homeassistant/components/elv/__init__.py @@ -2,8 +2,10 @@ import voluptuous as vol from homeassistant.const import CONF_DEVICE, Platform +from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType DOMAIN = "elv" @@ -21,7 +23,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the PCA switch platform.""" for platform in ELV_PLATFORMS: diff --git a/homeassistant/components/emoncms_history/__init__.py b/homeassistant/components/emoncms_history/__init__.py index 5cb639de67c..b4420ec6863 100644 --- a/homeassistant/components/emoncms_history/__init__.py +++ b/homeassistant/components/emoncms_history/__init__.py @@ -14,9 +14,11 @@ from homeassistant.const import ( STATE_UNAVAILABLE, STATE_UNKNOWN, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import state as state_helper import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import track_point_in_time +from homeassistant.helpers.typing import ConfigType from homeassistant.util import dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -40,7 +42,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Emoncms history component.""" conf = config[DOMAIN] whitelist = conf.get(CONF_WHITELIST) diff --git a/homeassistant/components/emulated_hue/__init__.py b/homeassistant/components/emulated_hue/__init__.py index 4dec35a80e8..d3586ab5fcf 100644 --- a/homeassistant/components/emulated_hue/__init__.py +++ b/homeassistant/components/emulated_hue/__init__.py @@ -11,8 +11,10 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import storage import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType from .hue_api import ( HueAllGroupsStateView, @@ -103,7 +105,7 @@ CONFIG_SCHEMA = vol.Schema( ATTR_EMULATED_HUE_NAME = "emulated_hue_name" -async def async_setup(hass, yaml_config): +async def async_setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool: """Activate the emulated_hue component.""" local_ip = await async_get_source_ip(hass) config = Config(hass, yaml_config.get(DOMAIN, {}), local_ip) diff --git a/homeassistant/components/emulated_roku/__init__.py b/homeassistant/components/emulated_roku/__init__.py index 3d84bf20f44..59929eab118 100644 --- a/homeassistant/components/emulated_roku/__init__.py +++ b/homeassistant/components/emulated_roku/__init__.py @@ -3,8 +3,11 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.components.network import async_get_source_ip +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType from .binding import EmulatedRoku from .config_flow import configured_servers @@ -43,7 +46,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the emulated roku component.""" if (conf := config.get(DOMAIN)) is None: return True @@ -61,7 +64,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up an emulated roku server from a config entry.""" config = config_entry.data @@ -90,7 +93,7 @@ async def async_setup_entry(hass, config_entry): return await server.setup() -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" name = entry.data[CONF_NAME] server = hass.data[DOMAIN].pop(name) diff --git a/homeassistant/components/enocean/__init__.py b/homeassistant/components/enocean/__init__.py index c13f71a1432..18c3b888d19 100644 --- a/homeassistant/components/enocean/__init__.py +++ b/homeassistant/components/enocean/__init__.py @@ -1,11 +1,11 @@ """Support for EnOcean devices.""" - import voluptuous as vol -from homeassistant import config_entries, core -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import CONF_DEVICE +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType from .const import DATA_ENOCEAN, DOMAIN, ENOCEAN_DONGLE from .dongle import EnOceanDongle @@ -15,7 +15,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the EnOcean component.""" # support for text-based configuration (legacy) if DOMAIN not in config: @@ -35,9 +35,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry( - hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry -): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up an EnOcean dongle for the given entry.""" enocean_data = hass.data.setdefault(DATA_ENOCEAN, {}) usb_dongle = EnOceanDongle(hass, config_entry.data[CONF_DEVICE]) @@ -47,7 +45,7 @@ async def async_setup_entry( return True -async def async_unload_entry(hass, config_entry): +async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload ENOcean config entry.""" enocean_dongle = hass.data[DATA_ENOCEAN][ENOCEAN_DONGLE] diff --git a/homeassistant/components/environment_canada/__init__.py b/homeassistant/components/environment_canada/__init__.py index 9b5ce11861c..ec41e5266e0 100644 --- a/homeassistant/components/environment_canada/__init__.py +++ b/homeassistant/components/environment_canada/__init__.py @@ -5,7 +5,9 @@ import xml.etree.ElementTree as et from env_canada import ECRadar, ECWeather, ec_exc +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform +from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import CONF_LANGUAGE, CONF_STATION, DOMAIN @@ -18,7 +20,7 @@ PLATFORMS = [Platform.CAMERA, Platform.SENSOR, Platform.WEATHER] _LOGGER = logging.getLogger(__name__) -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up EC as config entry.""" lat = config_entry.data.get(CONF_LATITUDE) lon = config_entry.data.get(CONF_LONGITUDE) @@ -51,7 +53,7 @@ async def async_setup_entry(hass, config_entry): return True -async def async_unload_entry(hass, config_entry): +async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms( config_entry, PLATFORMS diff --git a/homeassistant/components/eufy/__init__.py b/homeassistant/components/eufy/__init__.py index 2b006deb4e8..ffa30aa6262 100644 --- a/homeassistant/components/eufy/__init__.py +++ b/homeassistant/components/eufy/__init__.py @@ -11,8 +11,10 @@ from homeassistant.const import ( CONF_TYPE, CONF_USERNAME, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType DOMAIN = "eufy" @@ -51,7 +53,7 @@ EUFY_DISPATCH = { } -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up Eufy devices.""" if CONF_USERNAME in config[DOMAIN] and CONF_PASSWORD in config[DOMAIN]: