From d57c54c93e1f1b526fd8984402f4dc734147abdc Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sat, 1 Jan 2022 22:38:11 +0100 Subject: [PATCH] Add init type hints [f-g] (#63186) Co-authored-by: epenet --- homeassistant/components/fibaro/__init__.py | 4 +++- homeassistant/components/folder_watcher/__init__.py | 4 +++- homeassistant/components/forked_daapd/__init__.py | 6 ++++-- homeassistant/components/foscam/__init__.py | 2 +- homeassistant/components/freebox/__init__.py | 3 ++- homeassistant/components/freedns/__init__.py | 4 +++- .../components/fritzbox_callmonitor/__init__.py | 8 +++++--- homeassistant/components/gc100/__init__.py | 4 +++- homeassistant/components/gdacs/__init__.py | 11 ++++++----- .../components/generic_hygrostat/__init__.py | 5 +++-- homeassistant/components/geo_location/__init__.py | 3 ++- homeassistant/components/geofency/__init__.py | 9 ++++++--- homeassistant/components/geonetnz_quakes/__init__.py | 11 ++++++----- homeassistant/components/geonetnz_volcano/__init__.py | 11 ++++++----- homeassistant/components/glances/__init__.py | 6 +++--- homeassistant/components/goalfeed/__init__.py | 4 +++- homeassistant/components/google/__init__.py | 5 +++-- homeassistant/components/google_domains/__init__.py | 4 +++- homeassistant/components/gpslogger/__init__.py | 9 ++++++--- homeassistant/components/graphite/__init__.py | 4 +++- homeassistant/components/growatt_server/__init__.py | 3 ++- 21 files changed, 76 insertions(+), 44 deletions(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 7e638b1224c..5f76681a69f 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -20,9 +20,11 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_STOP, Platform, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity +from homeassistant.helpers.typing import ConfigType from homeassistant.util import convert, slugify _LOGGER = logging.getLogger(__name__) @@ -354,7 +356,7 @@ class FibaroController: pass -def setup(hass, base_config): +def setup(hass: HomeAssistant, base_config: ConfigType) -> bool: """Set up the Fibaro Component.""" gateways = base_config[DOMAIN][CONF_GATEWAYS] hass.data[FIBARO_CONTROLLERS] = {} diff --git a/homeassistant/components/folder_watcher/__init__.py b/homeassistant/components/folder_watcher/__init__.py index 7d3b1ec7660..e718c3d3bf2 100644 --- a/homeassistant/components/folder_watcher/__init__.py +++ b/homeassistant/components/folder_watcher/__init__.py @@ -7,7 +7,9 @@ from watchdog.events import PatternMatchingEventHandler from watchdog.observers import Observer from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -36,7 +38,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the folder watcher.""" conf = config[DOMAIN] for watcher in conf: diff --git a/homeassistant/components/forked_daapd/__init__.py b/homeassistant/components/forked_daapd/__init__.py index ea2d678aab5..903a56ce559 100644 --- a/homeassistant/components/forked_daapd/__init__.py +++ b/homeassistant/components/forked_daapd/__init__.py @@ -1,18 +1,20 @@ """The forked_daapd component.""" +from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform +from homeassistant.core import HomeAssistant from .const import DOMAIN, HASS_DATA_REMOVE_LISTENERS_KEY, HASS_DATA_UPDATER_KEY PLATFORMS = [Platform.MEDIA_PLAYER] -async def async_setup_entry(hass, entry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up forked-daapd from a config entry by forwarding to platform.""" 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: """Remove forked-daapd component.""" status = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if status and hass.data.get(DOMAIN) and hass.data[DOMAIN].get(entry.entry_id): diff --git a/homeassistant/components/foscam/__init__.py b/homeassistant/components/foscam/__init__.py index 380e1d18280..da2d61ef369 100644 --- a/homeassistant/components/foscam/__init__.py +++ b/homeassistant/components/foscam/__init__.py @@ -41,7 +41,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return unload_ok -async def async_migrate_entry(hass, entry: ConfigEntry): +async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Migrate old entry.""" LOGGER.debug("Migrating from version %s", entry.version) diff --git a/homeassistant/components/freebox/__init__.py b/homeassistant/components/freebox/__init__.py index 565d43b2a41..ee8c2f30975 100644 --- a/homeassistant/components/freebox/__init__.py +++ b/homeassistant/components/freebox/__init__.py @@ -7,6 +7,7 @@ from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, PLATFORMS, SERVICE_REBOOT from .router import FreeboxRouter @@ -26,7 +27,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Freebox integration.""" if DOMAIN in config: for entry_config in config[DOMAIN]: diff --git a/homeassistant/components/freedns/__init__.py b/homeassistant/components/freedns/__init__.py index 754e6cb8818..30bddbdaeee 100644 --- a/homeassistant/components/freedns/__init__.py +++ b/homeassistant/components/freedns/__init__.py @@ -8,7 +8,9 @@ import async_timeout import voluptuous as vol from homeassistant.const import CONF_ACCESS_TOKEN, CONF_SCAN_INTERVAL, CONF_URL +from homeassistant.core import HomeAssistant 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( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the FreeDNS component.""" conf = config[DOMAIN] url = conf.get(CONF_URL) diff --git a/homeassistant/components/fritzbox_callmonitor/__init__.py b/homeassistant/components/fritzbox_callmonitor/__init__.py index 4c36ee3ddfb..812d7a7db59 100644 --- a/homeassistant/components/fritzbox_callmonitor/__init__.py +++ b/homeassistant/components/fritzbox_callmonitor/__init__.py @@ -4,7 +4,9 @@ import logging from fritzconnection.core.exceptions import FritzConnectionException, FritzSecurityError from requests.exceptions import ConnectionError as RequestsConnectionError +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from .base import FritzBoxPhonebook @@ -20,7 +22,7 @@ from .const import ( _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 the fritzbox_callmonitor platforms.""" fritzbox_phonebook = FritzBoxPhonebook( host=config_entry.data[CONF_HOST], @@ -58,7 +60,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: """Unloading the fritzbox_callmonitor platforms.""" unload_ok = await hass.config_entries.async_unload_platforms( @@ -73,6 +75,6 @@ async def async_unload_entry(hass, config_entry): return unload_ok -async def update_listener(hass, config_entry): +async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None: """Update listener to reload after option has changed.""" await hass.config_entries.async_reload(config_entry.entry_id) diff --git a/homeassistant/components/gc100/__init__.py b/homeassistant/components/gc100/__init__.py index 51abd9d5693..fff68f48fc0 100644 --- a/homeassistant/components/gc100/__init__.py +++ b/homeassistant/components/gc100/__init__.py @@ -3,7 +3,9 @@ import gc100 import voluptuous as vol from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType CONF_PORTS = "ports" @@ -25,7 +27,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, base_config): +def setup(hass: HomeAssistant, base_config: ConfigType) -> bool: """Set up the gc100 component.""" config = base_config[DOMAIN] host = config[CONF_HOST] diff --git a/homeassistant/components/gdacs/__init__.py b/homeassistant/components/gdacs/__init__.py index b637d59b66c..b585658befb 100644 --- a/homeassistant/components/gdacs/__init__.py +++ b/homeassistant/components/gdacs/__init__.py @@ -5,7 +5,7 @@ import logging from aio_georss_gdacs import GdacsFeedManager import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_LATITUDE, CONF_LONGITUDE, @@ -14,10 +14,11 @@ from homeassistant.const import ( CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_MILES, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType from homeassistant.util.unit_system import METRIC_SYSTEM from .const import ( @@ -52,7 +53,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the GDACS component.""" if DOMAIN not in config: return True @@ -80,7 +81,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 GDACS component as config entry.""" hass.data.setdefault(DOMAIN, {}) feeds = hass.data[DOMAIN].setdefault(FEED, {}) @@ -96,7 +97,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 an GDACS component config entry.""" manager = hass.data[DOMAIN][FEED].pop(entry.entry_id) await manager.async_stop() diff --git a/homeassistant/components/generic_hygrostat/__init__.py b/homeassistant/components/generic_hygrostat/__init__.py index 20877f63369..b622ee5cb6e 100644 --- a/homeassistant/components/generic_hygrostat/__init__.py +++ b/homeassistant/components/generic_hygrostat/__init__.py @@ -1,10 +1,11 @@ """The generic_hygrostat component.""" - import voluptuous as vol from homeassistant.components.humidifier import HumidifierDeviceClass from homeassistant.const import CONF_NAME +from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, discovery +from homeassistant.helpers.typing import ConfigType DOMAIN = "generic_hygrostat" @@ -56,7 +57,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Generic Hygrostat component.""" if DOMAIN not in config: return True diff --git a/homeassistant/components/geo_location/__init__.py b/homeassistant/components/geo_location/__init__.py index c32917cb5cd..e58391ca84a 100644 --- a/homeassistant/components/geo_location/__init__.py +++ b/homeassistant/components/geo_location/__init__.py @@ -14,6 +14,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401 ) from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.helpers.typing import ConfigType # mypy: allow-untyped-defs, no-check-untyped-defs @@ -29,7 +30,7 @@ ENTITY_ID_FORMAT = DOMAIN + ".{}" SCAN_INTERVAL = timedelta(seconds=60) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Geolocation component.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL diff --git a/homeassistant/components/geofency/__init__.py b/homeassistant/components/geofency/__init__.py index 1191b72ba3f..063804f5726 100644 --- a/homeassistant/components/geofency/__init__.py +++ b/homeassistant/components/geofency/__init__.py @@ -4,6 +4,7 @@ from http import HTTPStatus from aiohttp import web import voluptuous as vol +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_LATITUDE, ATTR_LONGITUDE, @@ -12,9 +13,11 @@ from homeassistant.const import ( STATE_NOT_HOME, 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 homeassistant.util import slugify from .const import DOMAIN @@ -72,7 +75,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 Geofency component.""" config = hass_config.get(DOMAIN, {}) mobile_beacons = config.get(CONF_MOBILE_BEACONS, []) @@ -134,7 +137,7 @@ def _set_location(hass, data, location_name): 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, "Geofency", entry.data[CONF_WEBHOOK_ID], handle_webhook @@ -144,7 +147,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/geonetnz_quakes/__init__.py b/homeassistant/components/geonetnz_quakes/__init__.py index 23b08103a68..d9c27e9dff8 100644 --- a/homeassistant/components/geonetnz_quakes/__init__.py +++ b/homeassistant/components/geonetnz_quakes/__init__.py @@ -5,7 +5,7 @@ import logging from aio_geojson_geonetnz_quakes import GeonetnzQuakesFeedManager import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_LATITUDE, CONF_LONGITUDE, @@ -14,10 +14,11 @@ from homeassistant.const import ( CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_MILES, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType from homeassistant.util.unit_system import METRIC_SYSTEM from .const import ( @@ -58,7 +59,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the GeoNet NZ Quakes component.""" if DOMAIN not in config: return True @@ -87,7 +88,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 GeoNet NZ Quakes component as config entry.""" hass.data.setdefault(DOMAIN, {}) feeds = hass.data[DOMAIN].setdefault(FEED, {}) @@ -103,7 +104,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 an GeoNet NZ Quakes component config entry.""" manager = hass.data[DOMAIN][FEED].pop(entry.entry_id) await manager.async_stop() diff --git a/homeassistant/components/geonetnz_volcano/__init__.py b/homeassistant/components/geonetnz_volcano/__init__.py index dee87e54437..8d0733aacd1 100644 --- a/homeassistant/components/geonetnz_volcano/__init__.py +++ b/homeassistant/components/geonetnz_volcano/__init__.py @@ -7,7 +7,7 @@ import logging from aio_geojson_geonetnz_volcano import GeonetnzVolcanoFeedManager import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_LATITUDE, CONF_LONGITUDE, @@ -17,10 +17,11 @@ from homeassistant.const import ( CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_MILES, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType from homeassistant.util.unit_system import METRIC_SYSTEM from .config_flow import configured_instances @@ -45,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 GeoNet NZ Volcano component.""" if DOMAIN not in config: return True @@ -76,7 +77,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 GeoNet NZ Volcano component as config entry.""" hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN].setdefault(FEED, {}) @@ -93,7 +94,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 an GeoNet NZ Volcano component config entry.""" manager = hass.data[DOMAIN][FEED].pop(entry.entry_id) await manager.async_stop() diff --git a/homeassistant/components/glances/__init__.py b/homeassistant/components/glances/__init__.py index a2f662c4999..506c49967f6 100644 --- a/homeassistant/components/glances/__init__.py +++ b/homeassistant/components/glances/__init__.py @@ -5,7 +5,7 @@ import logging from glances_api import Glances, exceptions 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_NAME, @@ -74,7 +74,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: return True -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up Glances from config entry.""" client = GlancesData(hass, config_entry) hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = client @@ -84,7 +84,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 config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: diff --git a/homeassistant/components/goalfeed/__init__.py b/homeassistant/components/goalfeed/__init__.py index cdca99e0309..f452b858e79 100644 --- a/homeassistant/components/goalfeed/__init__.py +++ b/homeassistant/components/goalfeed/__init__.py @@ -6,7 +6,9 @@ import requests import voluptuous as vol from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType # Version downgraded due to regression in library # For details: https://github.com/nlsdfnbch/Pysher/issues/38 @@ -29,7 +31,7 @@ GOALFEED_AUTH_ENDPOINT = "https://goalfeed.ca/feed/auth" GOALFEED_APP_ID = "bfd4ed98c1ff22c04074" -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Goalfeed component.""" conf = config[DOMAIN] username = conf.get(CONF_USERNAME) diff --git a/homeassistant/components/google/__init__.py b/homeassistant/components/google/__init__.py index 52d60a8ca6c..2295bb9e629 100644 --- a/homeassistant/components/google/__init__.py +++ b/homeassistant/components/google/__init__.py @@ -24,11 +24,12 @@ from homeassistant.const import ( CONF_NAME, CONF_OFFSET, ) -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import generate_entity_id from homeassistant.helpers.event import track_utc_time_change +from homeassistant.helpers.typing import ConfigType from homeassistant.util import convert _LOGGER = logging.getLogger(__name__) @@ -229,7 +230,7 @@ def do_authentication(hass, hass_config, config): return True -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Google platform.""" if DATA_INDEX not in hass.data: hass.data[DATA_INDEX] = {} diff --git a/homeassistant/components/google_domains/__init__.py b/homeassistant/components/google_domains/__init__.py index 59386eb378a..51f29e6d68a 100644 --- a/homeassistant/components/google_domains/__init__.py +++ b/homeassistant/components/google_domains/__init__.py @@ -8,7 +8,9 @@ import async_timeout import voluptuous as vol from homeassistant.const import CONF_DOMAIN, CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -33,7 +35,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the Google Domains component.""" domain = config[DOMAIN].get(CONF_DOMAIN) user = config[DOMAIN].get(CONF_USERNAME) diff --git a/homeassistant/components/gpslogger/__init__.py b/homeassistant/components/gpslogger/__init__.py index ebbac36659f..a86a7f352ae 100644 --- a/homeassistant/components/gpslogger/__init__.py +++ b/homeassistant/components/gpslogger/__init__.py @@ -5,10 +5,13 @@ from aiohttp import web import voluptuous as vol from homeassistant.components.device_tracker import ATTR_BATTERY +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, 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 GPSLogger component.""" hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}} return True @@ -89,7 +92,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, "GPSLogger", entry.data[CONF_WEBHOOK_ID], handle_webhook @@ -100,7 +103,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/graphite/__init__.py b/homeassistant/components/graphite/__init__.py index b63e461e76a..0a6f6fcc1a9 100644 --- a/homeassistant/components/graphite/__init__.py +++ b/homeassistant/components/graphite/__init__.py @@ -17,8 +17,10 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_STOP, EVENT_STATE_CHANGED, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import state import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -47,7 +49,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Graphite feeder.""" conf = config[DOMAIN] host = conf.get(CONF_HOST) diff --git a/homeassistant/components/growatt_server/__init__.py b/homeassistant/components/growatt_server/__init__.py index 8fcc7c3f34d..f77323bf536 100644 --- a/homeassistant/components/growatt_server/__init__.py +++ b/homeassistant/components/growatt_server/__init__.py @@ -1,5 +1,6 @@ """The Growatt server PV inverter sensor integration.""" from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from .const import PLATFORMS @@ -14,6 +15,6 @@ async def async_setup_entry( return True -async def async_unload_entry(hass, entry): +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)