Add init type hints [k-l] (#63188)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-02 16:34:33 +01:00 committed by GitHub
parent 1d41e5b0c6
commit e02f0c34e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 57 additions and 26 deletions

View File

@ -9,10 +9,12 @@ from homeassistant.const import (
CONF_SCAN_INTERVAL, CONF_SCAN_INTERVAL,
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType
from .api_data import KaiterraApiData from .api_data import KaiterraApiData
from .const import ( from .const import (
@ -53,7 +55,7 @@ KAITERRA_SCHEMA = vol.Schema(
CONFIG_SCHEMA = vol.Schema({DOMAIN: KAITERRA_SCHEMA}, extra=vol.ALLOW_EXTRA) CONFIG_SCHEMA = vol.Schema({DOMAIN: KAITERRA_SCHEMA}, extra=vol.ALLOW_EXTRA)
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Kaiterra integration.""" """Set up the Kaiterra integration."""
conf = config[DOMAIN] conf = config[DOMAIN]

View File

@ -6,9 +6,10 @@ from keba_kecontact.connection import KebaKeContact
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.core import ServiceCall from homeassistant.core import HomeAssistant, ServiceCall
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
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -54,7 +55,7 @@ _SERVICE_MAP = {
} }
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Check connectivity and version of KEBA charging station.""" """Check connectivity and version of KEBA charging station."""
host = config[DOMAIN][CONF_HOST] host = config[DOMAIN][CONF_HOST]
rfid = config[DOMAIN][CONF_RFID] rfid = config[DOMAIN][CONF_RFID]

View File

@ -10,13 +10,15 @@ from homeassistant.const import (
SERVICE_VOLUME_MUTE, SERVICE_VOLUME_MUTE,
SERVICE_VOLUME_UP, SERVICE_VOLUME_UP,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
DOMAIN = "keyboard" DOMAIN = "keyboard"
TAP_KEY_SCHEMA = vol.Schema({}) TAP_KEY_SCHEMA = vol.Schema({})
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Listen for keyboard events.""" """Listen for keyboard events."""
keyboard = PyKeyboard() keyboard = PyKeyboard()

View File

@ -19,8 +19,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
STATE_UNKNOWN, STATE_UNKNOWN,
) )
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 = "kira" DOMAIN = "kira"
@ -92,7 +94,7 @@ def load_codes(path):
return codes return codes
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the KIRA component.""" """Set up the KIRA component."""
sensors = config.get(DOMAIN, {}).get(CONF_SENSORS, []) sensors = config.get(DOMAIN, {}).get(CONF_SENSORS, [])
remotes = config.get(DOMAIN, {}).get(CONF_REMOTES, []) remotes = config.get(DOMAIN, {}).get(CONF_REMOTES, [])

View File

@ -5,7 +5,9 @@ from lmnotify import LaMetricManager
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -27,7 +29,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the LaMetricManager.""" """Set up the LaMetricManager."""
_LOGGER.debug("Setting up LaMetric platform") _LOGGER.debug("Setting up LaMetric platform")
conf = config[DOMAIN] conf = config[DOMAIN]

View File

@ -3,8 +3,11 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PORT, Platform from homeassistant.const import CONF_PORT, Platform
from homeassistant.core import HomeAssistant
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
@ -29,7 +32,7 @@ DATA_LIFX_MANAGER = "lifx_manager"
PLATFORMS = [Platform.LIGHT] PLATFORMS = [Platform.LIGHT]
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the LIFX component.""" """Set up the LIFX component."""
conf = config.get(DOMAIN) conf = config.get(DOMAIN)
@ -45,13 +48,13 @@ async def async_setup(hass, config):
return True return True
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up LIFX from a config entry.""" """Set up LIFX from a config entry."""
hass.config_entries.async_setup_platforms(entry, PLATFORMS) hass.config_entries.async_setup_platforms(entry, PLATFORMS)
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.data.pop(DATA_LIFX_MANAGER).cleanup() hass.data.pop(DATA_LIFX_MANAGER).cleanup()
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -27,6 +27,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
) )
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -316,7 +317,7 @@ def filter_turn_on_params(light, params):
return params return params
async def async_setup(hass, config): # noqa: C901 async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: C901
"""Expose light control via state machine and services.""" """Expose light control via state machine and services."""
component = hass.data[DOMAIN] = EntityComponent( component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL _LOGGER, DOMAIN, hass, SCAN_INTERVAL

View File

@ -5,8 +5,10 @@ import voluptuous as vol
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import CONF_HOST, CONF_LIGHTS, CONF_NAME, CONF_SWITCHES from homeassistant.const import CONF_HOST, CONF_LIGHTS, CONF_NAME, CONF_SWITCHES
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.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
CONF_SERIAL = "serial" CONF_SERIAL = "serial"
CONF_PROXY_IP = "proxy_ip" CONF_PROXY_IP = "proxy_ip"
@ -58,7 +60,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Try to start embedded Lightwave broker.""" """Try to start embedded Lightwave broker."""
host = config[DOMAIN][CONF_HOST] host = config[DOMAIN][CONF_HOST]
lwlink = LWLink(host) lwlink = LWLink(host)

View File

@ -6,7 +6,9 @@ import linode
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_ACCESS_TOKEN, Platform from homeassistant.const import CONF_ACCESS_TOKEN, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -34,7 +36,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Linode component.""" """Set up the Linode component."""
conf = config[DOMAIN] conf = config[DOMAIN]
access_token = conf.get(CONF_ACCESS_TOKEN) access_token = conf.get(CONF_ACCESS_TOKEN)

View File

@ -7,6 +7,8 @@ import time
import lirc import lirc
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -19,7 +21,7 @@ EVENT_IR_COMMAND_RECEIVED = "ir_command_received"
ICON = "mdi:remote" ICON = "mdi:remote"
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the LIRC capability.""" """Set up the LIRC capability."""
# blocking=True gives unexpected behavior (multiple responses for 1 press) # blocking=True gives unexpected behavior (multiple responses for 1 press)
# also by not blocking, we allow hass to shut down the thread gracefully # also by not blocking, we allow hass to shut down the thread gracefully

View File

@ -10,6 +10,7 @@ from homeassistant.const import CONF_PORT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import CONF_EXCLUDE_NAMES, CONF_INCLUDE_SWITCHES, DOMAIN, PLATFORMS from .const import CONF_EXCLUDE_NAMES, CONF_INCLUDE_SWITCHES, DOMAIN, PLATFORMS
@ -34,7 +35,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the LiteJet component.""" """Set up the LiteJet component."""
if DOMAIN in config and not hass.config_entries.async_entries(DOMAIN): if DOMAIN in config and not hass.config_entries.async_entries(DOMAIN):
# No config entry exists and configuration.yaml config exists, trigger the import flow. # No config entry exists and configuration.yaml config exists, trigger the import flow.

View File

@ -7,6 +7,7 @@ import logging
from aiohttp import web from aiohttp import web
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_ID, ATTR_ID,
ATTR_LATITUDE, ATTR_LATITUDE,
@ -15,9 +16,11 @@ from homeassistant.const import (
STATE_NOT_HOME, STATE_NOT_HOME,
Platform, Platform,
) )
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.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -57,7 +60,7 @@ WEBHOOK_SCHEMA = vol.All(
) )
async def async_setup(hass, hass_config): async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
"""Set up the Locative component.""" """Set up the Locative component."""
hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}} hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}}
return True return True
@ -111,7 +114,7 @@ async def handle_webhook(hass, webhook_id, request):
) )
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, "Locative", entry.data[CONF_WEBHOOK_ID], handle_webhook DOMAIN, "Locative", entry.data[CONF_WEBHOOK_ID], handle_webhook
@ -121,7 +124,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])
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)() hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()

View File

@ -6,8 +6,10 @@ import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_TOKEN, EVENT_STATE_CHANGED from homeassistant.const import CONF_TOKEN, EVENT_STATE_CHANGED
from homeassistant.core import HomeAssistant
from homeassistant.helpers import state as state_helper from homeassistant.helpers import state as state_helper
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -20,7 +22,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Logentries component.""" """Set up the Logentries component."""
conf = config[DOMAIN] conf = config[DOMAIN]
token = conf.get(CONF_TOKEN) token = conf.get(CONF_TOKEN)

View File

@ -3,8 +3,9 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.core import ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
DOMAIN = "logger" DOMAIN = "logger"
@ -49,7 +50,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the logger component.""" """Set up the logger component."""
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
logging.setLoggerClass(_get_logger_class(hass.data[DOMAIN])) logging.setLoggerClass(_get_logger_class(hass.data[DOMAIN]))

View File

@ -9,6 +9,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.camera import ATTR_FILENAME from homeassistant.components.camera import ATTR_FILENAME
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
ATTR_MODE, ATTR_MODE,
@ -20,9 +21,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
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.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
from . import config_flow from . import config_flow
from .const import ( from .const import (
@ -101,7 +103,7 @@ LOGI_CIRCLE_SERVICE_RECORD = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up configured Logi Circle component.""" """Set up configured Logi Circle component."""
if DOMAIN not in config: if DOMAIN not in config:
return True return True
@ -127,7 +129,7 @@ async def async_setup(hass, config):
return True return True
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Logi Circle from a config entry.""" """Set up Logi Circle from a config entry."""
logi_circle = LogiCircle( logi_circle = LogiCircle(
client_id=entry.data[CONF_CLIENT_ID], client_id=entry.data[CONF_CLIENT_ID],
@ -228,7 +230,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."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -13,8 +13,10 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
Platform, Platform,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -44,7 +46,7 @@ LUPUSEC_PLATFORMS = [
] ]
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Lupusec component.""" """Set up Lupusec component."""
conf = config[DOMAIN] conf = config[DOMAIN]
username = conf[CONF_USERNAME] username = conf[CONF_USERNAME]

View File

@ -18,6 +18,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
ACTION_PRESS, ACTION_PRESS,
@ -77,7 +78,7 @@ PLATFORMS = [
] ]
async def async_setup(hass, base_config): async def async_setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
"""Set up the Lutron component.""" """Set up the Lutron component."""
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})