diff --git a/homeassistant/components/tankerkoenig/__init__.py b/homeassistant/components/tankerkoenig/__init__.py index b85f3482a5d..5cbe6e0b9a8 100644 --- a/homeassistant/components/tankerkoenig/__init__.py +++ b/homeassistant/components/tankerkoenig/__init__.py @@ -15,9 +15,11 @@ from homeassistant.const import ( CONF_SCAN_INTERVAL, CONF_SHOW_ON_MAP, ) +from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import async_load_platform +from homeassistant.helpers.typing import ConfigType from .const import CONF_FUEL_TYPES, CONF_STATIONS, DOMAIN, FUEL_TYPES @@ -61,7 +63,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set the tankerkoenig component up.""" if DOMAIN not in config: return True diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index c9123218f45..7c03ecab271 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -29,9 +29,10 @@ from homeassistant.const import ( HTTP_BEARER_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION, ) -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import TemplateError import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -299,7 +300,7 @@ def load_data( return None -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Telegram bot component.""" if not config[DOMAIN]: return False diff --git a/homeassistant/components/tellduslive/__init__.py b/homeassistant/components/tellduslive/__init__.py index 716dd8fb1d3..572950b816b 100644 --- a/homeassistant/components/tellduslive/__init__.py +++ b/homeassistant/components/tellduslive/__init__.py @@ -7,10 +7,13 @@ from tellduslive import DIM, TURNON, UP, Session import voluptuous as vol from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_call_later +from homeassistant.helpers.typing import ConfigType from .const import ( DOMAIN, @@ -49,7 +52,7 @@ NEW_CLIENT_TASK = "telldus_new_client_task" INTERVAL_TRACKER = f"{DOMAIN}_INTERVAL" -async def async_setup_entry(hass, entry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Create a tellduslive session.""" conf = entry.data[KEY_SESSION] @@ -95,7 +98,7 @@ async def async_new_client(hass, session, entry): await client.update() -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Telldus Live component.""" if DOMAIN not in config: return True @@ -113,7 +116,7 @@ async def async_setup(hass, config): 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.""" if not hass.data[NEW_CLIENT_TASK].done(): hass.data[NEW_CLIENT_TASK].cancel() diff --git a/homeassistant/components/tellstick/__init__.py b/homeassistant/components/tellstick/__init__.py index db37f4669d3..65e96bc5280 100644 --- a/homeassistant/components/tellstick/__init__.py +++ b/homeassistant/components/tellstick/__init__.py @@ -14,10 +14,11 @@ from tellcorenet import TellCoreClient import voluptuous as vol from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -80,7 +81,7 @@ def _discover(hass, config, component_name, found_tellcore_devices): ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Tellstick component.""" conf = config.get(DOMAIN, {}) diff --git a/homeassistant/components/template/__init__.py b/homeassistant/components/template/__init__.py index 329c03063e5..318b457c24b 100644 --- a/homeassistant/components/template/__init__.py +++ b/homeassistant/components/template/__init__.py @@ -11,7 +11,7 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_START, SERVICE_RELOAD, ) -from homeassistant.core import CoreState, Event, ServiceCall, callback +from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import ( discovery, @@ -19,6 +19,7 @@ from homeassistant.helpers import ( update_coordinator, ) from homeassistant.helpers.reload import async_reload_integration_platforms +from homeassistant.helpers.typing import ConfigType from homeassistant.loader import async_get_integration from .const import CONF_TRIGGER, DOMAIN, PLATFORMS @@ -26,7 +27,7 @@ from .const import CONF_TRIGGER, DOMAIN, PLATFORMS _LOGGER = logging.getLogger(__name__) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the template integration.""" if DOMAIN in config: await _process_config(hass, config) @@ -125,7 +126,7 @@ class TriggerUpdateCoordinator(update_coordinator.DataUpdateCoordinator): if self._unsub_trigger: self._unsub_trigger() - async def async_setup(self, hass_config): + async def async_setup(self: HomeAssistant, hass_config: ConfigType) -> bool: """Set up the trigger and create entities.""" if self.hass.state == CoreState.running: await self._attach_triggers() diff --git a/homeassistant/components/thethingsnetwork/__init__.py b/homeassistant/components/thethingsnetwork/__init__.py index c31b4dc7bcd..af0f9965f56 100644 --- a/homeassistant/components/thethingsnetwork/__init__.py +++ b/homeassistant/components/thethingsnetwork/__init__.py @@ -1,8 +1,9 @@ """Support for The Things network.""" - import voluptuous as vol +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType CONF_ACCESS_KEY = "access_key" CONF_APP_ID = "app_id" @@ -29,7 +30,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize of The Things Network component.""" conf = config[DOMAIN] app_id = conf.get(CONF_APP_ID) diff --git a/homeassistant/components/thingspeak/__init__.py b/homeassistant/components/thingspeak/__init__.py index 0eccfbbcd04..e4788674845 100644 --- a/homeassistant/components/thingspeak/__init__.py +++ b/homeassistant/components/thingspeak/__init__.py @@ -12,8 +12,10 @@ from homeassistant.const import ( STATE_UNAVAILABLE, STATE_UNKNOWN, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import event, state as state_helper import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -35,7 +37,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Thingspeak environment.""" conf = config[DOMAIN] api_key = conf.get(CONF_API_KEY) diff --git a/homeassistant/components/toon/__init__.py b/homeassistant/components/toon/__init__.py index 7d442130130..3d00d6216a0 100644 --- a/homeassistant/components/toon/__init__.py +++ b/homeassistant/components/toon/__init__.py @@ -1,5 +1,4 @@ """Support for Toon van Eneco devices.""" - import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry diff --git a/homeassistant/components/totalconnect/__init__.py b/homeassistant/components/totalconnect/__init__.py index 05566708f22..641c0c4477a 100644 --- a/homeassistant/components/totalconnect/__init__.py +++ b/homeassistant/components/totalconnect/__init__.py @@ -51,7 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return True -async def async_unload_entry(hass, entry: ConfigEntry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: diff --git a/homeassistant/components/tplink_lte/__init__.py b/homeassistant/components/tplink_lte/__init__.py index 7ea7e24dbb9..32e0027a3b4 100644 --- a/homeassistant/components/tplink_lte/__init__.py +++ b/homeassistant/components/tplink_lte/__init__.py @@ -14,9 +14,10 @@ from homeassistant.const import ( CONF_RECIPIENT, EVENT_HOMEASSISTANT_STOP, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.aiohttp_client import async_create_clientsession +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -80,7 +81,7 @@ class LTEData: return None -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up TP-Link LTE component.""" if DATA_KEY not in hass.data: websession = async_create_clientsession( diff --git a/homeassistant/components/traccar/__init__.py b/homeassistant/components/traccar/__init__.py index 1d656d75c47..4a78903aa9f 100644 --- a/homeassistant/components/traccar/__init__.py +++ b/homeassistant/components/traccar/__init__.py @@ -4,10 +4,13 @@ from http import HTTPStatus from aiohttp import web import voluptuous as vol +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ID, CONF_WEBHOOK_ID, Platform +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_entry_flow import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send +from homeassistant.helpers.typing import ConfigType from .const import ( ATTR_ACCURACY, @@ -51,7 +54,7 @@ WEBHOOK_SCHEMA = vol.Schema( ) -async def async_setup(hass, hass_config): +async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool: """Set up the Traccar component.""" hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}} return True @@ -88,7 +91,7 @@ async def handle_webhook(hass, webhook_id, request): return web.Response(text=f"Setting location for {device}") -async def async_setup_entry(hass, entry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, "Traccar", entry.data[CONF_WEBHOOK_ID], handle_webhook @@ -98,7 +101,7 @@ async def async_setup_entry(hass, entry): return True -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)() diff --git a/homeassistant/components/trace/__init__.py b/homeassistant/components/trace/__init__.py index 29ed9f4d062..14783fd3f84 100644 --- a/homeassistant/components/trace/__init__.py +++ b/homeassistant/components/trace/__init__.py @@ -10,7 +10,7 @@ from typing import Any import voluptuous as vol from homeassistant.const import EVENT_HOMEASSISTANT_STOP -from homeassistant.core import Context +from homeassistant.core import Context, HomeAssistant from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.json import ExtendedJSONEncoder @@ -22,6 +22,7 @@ from homeassistant.helpers.trace import ( trace_id_set, trace_set_child_id, ) +from homeassistant.helpers.typing import ConfigType import homeassistant.util.dt as dt_util import homeassistant.util.uuid as uuid_util @@ -47,7 +48,7 @@ TRACE_CONFIG_SCHEMA = { } -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the trace integration.""" hass.data[DATA_TRACE] = {} websocket_api.async_setup(hass) diff --git a/homeassistant/components/transmission/__init__.py b/homeassistant/components/transmission/__init__.py index ae251582e95..6b9d8c0aeb1 100644 --- a/homeassistant/components/transmission/__init__.py +++ b/homeassistant/components/transmission/__init__.py @@ -8,7 +8,7 @@ import transmissionrpc from transmissionrpc.error import TransmissionError import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_HOST, CONF_ID, @@ -19,11 +19,12 @@ from homeassistant.const import ( CONF_USERNAME, Platform, ) -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv from homeassistant.helpers.dispatcher import dispatcher_send from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType from .const import ( ATTR_DELETE_DATA, @@ -100,7 +101,7 @@ CONFIG_SCHEMA = vol.Schema( PLATFORMS = [Platform.SENSOR, Platform.SWITCH] -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Import the Transmission Component from config.""" if DOMAIN in config: for entry in config[DOMAIN]: @@ -113,7 +114,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 the Transmission Component.""" client = TransmissionClient(hass, config_entry) hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = client @@ -124,7 +125,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 Transmission Entry from config_entry.""" client = hass.data[DOMAIN].pop(config_entry.entry_id) if client.unsub_timer: diff --git a/homeassistant/components/twilio/__init__.py b/homeassistant/components/twilio/__init__.py index 7c65a693af1..98b108fe94d 100644 --- a/homeassistant/components/twilio/__init__.py +++ b/homeassistant/components/twilio/__init__.py @@ -3,9 +3,12 @@ from twilio.rest import Client from twilio.twiml import TwiML import voluptuous as vol +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_WEBHOOK_ID +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_entry_flow import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN @@ -29,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Twilio component.""" if DOMAIN not in config: return True @@ -50,7 +53,7 @@ async def handle_webhook(hass, webhook_id, request): return TwiML().to_xml() -async def async_setup_entry(hass, entry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, "Twilio", entry.data[CONF_WEBHOOK_ID], handle_webhook @@ -58,7 +61,7 @@ async def async_setup_entry(hass, entry): return True -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True diff --git a/homeassistant/components/upb/__init__.py b/homeassistant/components/upb/__init__.py index acdf8c045a1..e4e1900d8f2 100644 --- a/homeassistant/components/upb/__init__.py +++ b/homeassistant/components/upb/__init__.py @@ -1,9 +1,9 @@ """Support the UPB PIM.""" - import upb_lib +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_COMMAND, CONF_FILE_PATH, CONF_HOST, Platform -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, Entity from .const import ( @@ -17,7 +17,7 @@ from .const import ( PLATFORMS = [Platform.LIGHT, Platform.SCENE] -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up a new config_entry for UPB PIM.""" url = config_entry.data[CONF_HOST] @@ -53,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 the config_entry.""" unload_ok = await hass.config_entries.async_unload_platforms( config_entry, PLATFORMS diff --git a/homeassistant/components/updater/__init__.py b/homeassistant/components/updater/__init__.py index 1d86dbaea8e..b02049b9f5e 100644 --- a/homeassistant/components/updater/__init__.py +++ b/homeassistant/components/updater/__init__.py @@ -8,9 +8,11 @@ from awesomeversion import AwesomeVersion import voluptuous as vol from homeassistant.const import __version__ as current_version +from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery, update_coordinator from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -53,7 +55,7 @@ class Updater: self.newest_version = newest_version -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the updater component.""" conf = config.get(DOMAIN, {})