Add init type hints [m] (#63189)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-02 16:28:14 +01:00 committed by GitHub
parent e7b262f9e5
commit 33e926371f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 58 additions and 31 deletions

View file

@ -6,9 +6,12 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_DOMAIN, CONF_WEBHOOK_ID from homeassistant.const import CONF_API_KEY, CONF_DOMAIN, CONF_WEBHOOK_ID
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_flow from homeassistant.helpers import config_entry_flow
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN from .const import DOMAIN
@ -34,7 +37,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Mailgun component.""" """Set up the Mailgun component."""
if DOMAIN not in config: if DOMAIN not in config:
return True return True
@ -84,7 +87,7 @@ async def verify_webhook(hass, token=None, timestamp=None, signature=None):
return hmac.compare_digest(signature, hmac_digest) return hmac.compare_digest(signature, hmac_digest)
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Configure based on config entry.""" """Configure based on config entry."""
hass.components.webhook.async_register( hass.components.webhook.async_register(
DOMAIN, "Mailgun", entry.data[CONF_WEBHOOK_ID], handle_webhook DOMAIN, "Mailgun", entry.data[CONF_WEBHOOK_ID], handle_webhook
@ -92,7 +95,7 @@ async def async_setup_entry(hass, entry):
return True return True
async def async_unload_entry(hass, entry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
return True return True

View file

@ -1,8 +1,11 @@
"""Support for showing device locations.""" """Support for showing device locations."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
DOMAIN = "map" DOMAIN = "map"
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Register the built-in map panel.""" """Register the built-in map panel."""
hass.components.frontend.async_register_built_in_panel( hass.components.frontend.async_register_built_in_panel(
"map", "map", "hass:tooltip-account" "map", "map", "hass:tooltip-account"

View file

@ -16,9 +16,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
from homeassistant.core import ServiceCall from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.json import load_json, save_json from homeassistant.util.json import load_json, save_json
from .const import DOMAIN, SERVICE_SEND_MESSAGE from .const import DOMAIN, SERVICE_SEND_MESSAGE
@ -81,7 +82,7 @@ SERVICE_SCHEMA_SEND_MESSAGE = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Matrix bot component.""" """Set up the Matrix bot component."""
config = config[DOMAIN] config = config[DOMAIN]

View file

@ -8,8 +8,10 @@ from maxcube.cube import MaxCube
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SCAN_INTERVAL from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import load_platform from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.dt import now from homeassistant.util.dt import now
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -46,7 +48,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Establish connection to MAX! Cube.""" """Establish connection to MAX! Cube."""
if DATA_KEY not in hass.data: if DATA_KEY not in hass.data:

View file

@ -13,8 +13,9 @@ from homeassistant.components.media_player.const import (
SERVICE_PLAY_MEDIA, SERVICE_PLAY_MEDIA,
) )
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import ServiceCall from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -39,7 +40,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the media extractor service.""" """Set up the media extractor service."""
def play_media(call: ServiceCall) -> None: def play_media(call: ServiceCall) -> None:

View file

@ -72,7 +72,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True 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 a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms( unload_ok = await hass.config_entries.async_unload_platforms(
config_entry, PLATFORMS config_entry, PLATFORMS

View file

@ -3,8 +3,10 @@ import melissa
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.typing import ConfigType
DOMAIN = "melissa" DOMAIN = "melissa"
DATA_MELISSA = "MELISSA" DATA_MELISSA = "MELISSA"
@ -23,7 +25,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Melissa Climate component.""" """Set up the Melissa Climate component."""
conf = config[DOMAIN] conf = config[DOMAIN]
username = conf.get(CONF_USERNAME) username = conf.get(CONF_USERNAME)

View file

@ -4,7 +4,9 @@ import logging
import meteireann import meteireann
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, Platform from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -18,7 +20,7 @@ UPDATE_INTERVAL = timedelta(minutes=60)
PLATFORMS = [Platform.WEATHER] PLATFORMS = [Platform.WEATHER]
async def async_setup_entry(hass, config_entry): async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Set up Met Éireann as config entry.""" """Set up Met Éireann as config entry."""
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
@ -54,7 +56,7 @@ async def async_setup_entry(hass, config_entry):
return True 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 a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms( unload_ok = await hass.config_entries.async_unload_platforms(
config_entry, PLATFORMS config_entry, PLATFORMS

View file

@ -1,7 +1,7 @@
"""The Mikrotik component.""" """The Mikrotik component."""
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_NAME, CONF_NAME,
@ -10,7 +10,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
ATTR_MANUFACTURER, ATTR_MANUFACTURER,
@ -52,7 +54,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Import the Mikrotik component from config.""" """Import the Mikrotik component from config."""
if DOMAIN in config: if DOMAIN in config:
@ -66,7 +68,7 @@ async def async_setup(hass, config):
return True return True
async def async_setup_entry(hass, config_entry): async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Set up the Mikrotik component.""" """Set up the Mikrotik component."""
hub = MikrotikHub(hass, config_entry) hub = MikrotikHub(hass, config_entry)
@ -87,7 +89,7 @@ async def async_setup_entry(hass, config_entry):
return True 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 a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms( unload_ok = await hass.config_entries.async_unload_platforms(
config_entry, PLATFORMS config_entry, PLATFORMS

View file

@ -7,6 +7,7 @@ import logging
from mill import Mill from mill import Mill
from mill_local import Mill as MillLocal from mill_local import Mill as MillLocal
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -42,7 +43,7 @@ class MillDataUpdateCoordinator(DataUpdateCoordinator):
) )
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up the Mill heater.""" """Set up the Mill heater."""
hass.data.setdefault(DOMAIN, {LOCAL: {}, CLOUD: {}}) hass.data.setdefault(DOMAIN, {LOCAL: {}, CLOUD: {}})
@ -79,6 +80,6 @@ async def async_setup_entry(hass, entry):
return True return True
async def async_unload_entry(hass, entry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View file

@ -9,8 +9,9 @@ import threading
import voluptuous as vol import voluptuous as vol
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import ServiceCall from homeassistant.core import HomeAssistant, ServiceCall
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .minio_helper import MinioEventThread, create_minio_client from .minio_helper import MinioEventThread, create_minio_client
@ -79,7 +80,7 @@ BUCKET_KEY_FILE_SCHEMA = BUCKET_KEY_SCHEMA.extend(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up MinioClient and event listeners.""" """Set up MinioClient and event listeners."""
conf = config[DOMAIN] conf = config[DOMAIN]

View file

@ -6,6 +6,7 @@ from homeassistant.components.webhook import (
async_register as webhook_register, async_register as webhook_register,
async_unregister as webhook_unregister, async_unregister as webhook_unregister,
) )
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_DEVICE_ID, CONF_WEBHOOK_ID, Platform from homeassistant.const import ATTR_DEVICE_ID, CONF_WEBHOOK_ID, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, discovery from homeassistant.helpers import device_registry as dr, discovery
@ -68,7 +69,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True return True
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a mobile_app entry.""" """Set up a mobile_app entry."""
registration = entry.data registration = entry.data
@ -99,7 +100,7 @@ async def async_setup_entry(hass, entry):
return True return True
async def async_unload_entry(hass, entry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a mobile app entry.""" """Unload a mobile app entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if not unload_ok: if not unload_ok:
@ -115,7 +116,7 @@ async def async_unload_entry(hass, entry):
return True return True
async def async_remove_entry(hass, entry): async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Cleanup when entry is removed.""" """Cleanup when entry is removed."""
hass.data[DOMAIN][DATA_DELETED_IDS].append(entry.data[CONF_WEBHOOK_ID]) hass.data[DOMAIN][DATA_DELETED_IDS].append(entry.data[CONF_WEBHOOK_ID])
store = hass.data[DOMAIN][DATA_STORE] store = hass.data[DOMAIN][DATA_STORE]

View file

@ -21,6 +21,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import websocket_api from homeassistant.components import websocket_api
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_CLIENT_ID, CONF_CLIENT_ID,
CONF_DISCOVERY, CONF_DISCOVERY,
@ -502,7 +503,7 @@ def _merge_config(entry, conf):
return {**conf, **entry.data} return {**conf, **entry.data}
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Load a config entry.""" """Load a config entry."""
conf = hass.data.get(DATA_MQTT_CONFIG) conf = hass.data.get(DATA_MQTT_CONFIG)

View file

@ -17,9 +17,10 @@ from homeassistant.const import (
EVENT_TIME_CHANGED, EVENT_TIME_CHANGED,
MATCH_ALL, MATCH_ALL,
) )
from homeassistant.core import EventOrigin, State, callback from homeassistant.core import EventOrigin, HomeAssistant, State, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.json import JSONEncoder from homeassistant.helpers.json import JSONEncoder
from homeassistant.helpers.typing import ConfigType
DOMAIN = "mqtt_eventstream" DOMAIN = "mqtt_eventstream"
CONF_PUBLISH_TOPIC = "publish_topic" CONF_PUBLISH_TOPIC = "publish_topic"
@ -52,7 +53,7 @@ BLOCKED_EVENTS = [
] ]
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the MQTT eventstream component.""" """Set up the MQTT eventstream component."""
conf = config.get(DOMAIN, {}) conf = config.get(DOMAIN, {})
pub_topic = conf.get(CONF_PUBLISH_TOPIC) pub_topic = conf.get(CONF_PUBLISH_TOPIC)

View file

@ -15,7 +15,7 @@ from .const import DOMAIN
PLATFORMS = [Platform.BINARY_SENSOR] PLATFORMS = [Platform.BINARY_SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: dict) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Mullvad VPN integration.""" """Set up Mullvad VPN integration."""
async def async_get_mullvad_api_data(): async def async_get_mullvad_api_data():

View file

@ -1,10 +1,12 @@
"""Support for my.home-assistant.io redirect service.""" """Support for my.home-assistant.io redirect service."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
DOMAIN = "my" DOMAIN = "my"
URL_PATH = "_my_redirect" URL_PATH = "_my_redirect"
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Register hidden _my_redirect panel.""" """Register hidden _my_redirect panel."""
hass.components.frontend.async_register_built_in_panel( hass.components.frontend.async_register_built_in_panel(
DOMAIN, frontend_url_path=URL_PATH DOMAIN, frontend_url_path=URL_PATH

View file

@ -2,8 +2,10 @@
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
DOMAIN = "mycroft" DOMAIN = "mycroft"
@ -12,7 +14,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Mycroft component.""" """Set up the Mycroft component."""
hass.data[DOMAIN] = config[DOMAIN][CONF_HOST] hass.data[DOMAIN] = config[DOMAIN][CONF_HOST]
discovery.load_platform(hass, "notify", DOMAIN, {}, config) discovery.load_platform(hass, "notify", DOMAIN, {}, config)

View file

@ -10,9 +10,11 @@ from homeassistant.const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_SCAN_INTERVAL, CONF_SCAN_INTERVAL,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType
DOMAIN = "mythicbeastsdns" DOMAIN = "mythicbeastsdns"
@ -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 Mythic Beasts component.""" """Initialize the Mythic Beasts component."""
domain = config[DOMAIN][CONF_DOMAIN] domain = config[DOMAIN][CONF_DOMAIN]
password = config[DOMAIN][CONF_PASSWORD] password = config[DOMAIN][CONF_PASSWORD]