Add init type hints [s] (#63193)

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

View file

@ -14,6 +14,7 @@ from homeassistant.const import CONF_PLATFORM, SERVICE_TURN_ON
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant
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
@ -58,7 +59,7 @@ PLATFORM_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the scenes."""
component = hass.data[DOMAIN] = EntityComponent(
logging.getLogger(__name__), DOMAIN, hass

View file

@ -9,8 +9,9 @@ from scsgate.tasks import GetStatusTask
import voluptuous as vol
from homeassistant.const import CONF_DEVICE, CONF_NAME
from homeassistant.core import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import EVENT_HOMEASSISTANT_STOP, HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -27,7 +28,7 @@ SCSGATE_SCHEMA = vol.Schema(
)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the SCSGate component."""
device = config[DOMAIN][CONF_DEVICE]
scsgate = None

View file

@ -1,5 +1,4 @@
"""Shark IQ Integration."""
import asyncio
from contextlib import suppress
@ -13,7 +12,9 @@ from sharkiqpy import (
)
from homeassistant import exceptions
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from .const import _LOGGER, API_TIMEOUT, DOMAIN, PLATFORMS
from .update_coordinator import SharkIqUpdateCoordinator
@ -39,7 +40,7 @@ async def async_connect_or_timeout(ayla_api: AylaApi) -> bool:
return True
async def async_setup_entry(hass, config_entry):
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Initialize the sharkiq platform via config entry."""
ayla_api = get_ayla_api(
username=config_entry.data[CONF_USERNAME],
@ -83,7 +84,7 @@ async def async_update_options(hass, config_entry):
await hass.config_entries.async_reload(config_entry.entry_id)
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

View file

@ -8,8 +8,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP,
EVENT_STATE_CHANGED,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import state as state_helper
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
DOMAIN = "shiftr"
@ -28,7 +30,7 @@ CONFIG_SCHEMA = vol.Schema(
)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Initialize the Shiftr.io MQTT consumer."""
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)

View file

@ -1,6 +1,8 @@
"""The sky_hub component."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the sky_hub component."""
return True

View file

@ -11,8 +11,10 @@ from homeassistant.const import (
CONF_USERNAME,
__version__,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
_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 Skybell component."""
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)

View file

@ -6,9 +6,11 @@ from sleepyq import Sleepyq
import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
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 Throttle
from .const import DOMAIN
@ -30,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema(
)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the SleepIQ component.
Will automatically load sensor components to support

View file

@ -1,5 +1,4 @@
"""Component for the Slide API."""
from datetime import timedelta
import logging
@ -15,9 +14,11 @@ from homeassistant.const import (
STATE_OPEN,
STATE_OPENING,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.event import async_call_later, async_track_time_interval
from homeassistant.helpers.typing import ConfigType
from .const import (
API,
@ -50,7 +51,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Slide platform."""
async def update_slides(now=None):

View file

@ -1,5 +1,7 @@
"""SmartTub integration."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from .const import DOMAIN, SMARTTUB_CONTROLLER
from .controller import SmartTubController
@ -13,7 +15,7 @@ PLATFORMS = [
]
async def async_setup_entry(hass, entry):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a smarttub config entry."""
controller = SmartTubController(hass)
@ -30,7 +32,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:
"""Remove a smarttub config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:

View file

@ -1,5 +1,4 @@
"""Support to control a Salda Smarty XP/XV ventilation unit."""
from datetime import timedelta
import ipaddress
import logging
@ -8,10 +7,12 @@ from pysmarty import Smarty
import voluptuous as vol
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import dispatcher_send
from homeassistant.helpers.event import track_time_interval
from homeassistant.helpers.typing import ConfigType
DOMAIN = "smarty"
DATA_SMARTY = "smarty"
@ -35,7 +36,7 @@ RPM = "rpm"
SIGNAL_UPDATE_SMARTY = "smarty_update"
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the smarty environment."""
conf = config[DOMAIN]

View file

@ -1,11 +1,11 @@
"""The sms component."""
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_DEVICE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN, SMS_GATEWAY
from .gateway import create_sms_gateway
@ -18,7 +18,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Configure Gammu state machine."""
hass.data.setdefault(DOMAIN, {})
if not (sms_config := config.get(DOMAIN, {})):

View file

@ -6,8 +6,9 @@ import logging
import voluptuous as vol
from homeassistant.components import mqtt
from homeassistant.core import ServiceCall
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers import config_validation as cv, intent
from homeassistant.helpers.typing import ConfigType
DOMAIN = "snips"
CONF_INTENTS = "intents"
@ -87,7 +88,7 @@ SERVICE_SCHEMA_FEEDBACK = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Activate Snips component."""
async def async_set_feedback(site_ids, state):

View file

@ -27,7 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
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)

View file

@ -1,5 +1,4 @@
"""Support for Soma Smartshades."""
from api.soma_api import SomaApi
import voluptuous as vol
@ -9,6 +8,7 @@ from homeassistant.const import CONF_HOST, CONF_PORT, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.typing import ConfigType
from .const import API, DOMAIN, HOST, PORT
@ -29,7 +29,7 @@ CONFIG_SCHEMA = vol.Schema(
PLATFORMS = [Platform.COVER, Platform.SENSOR]
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Soma component."""
if DOMAIN not in config:
return True

View file

@ -18,6 +18,7 @@ from homeassistant.helpers import (
config_validation as cv,
device_registry as dr,
)
from homeassistant.helpers.typing import ConfigType
from . import api, config_flow
from .const import COORDINATOR, DOMAIN
@ -52,7 +53,7 @@ PLATFORMS = [
]
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Somfy component."""
hass.data[DOMAIN] = {}
domain_config = config.get(DOMAIN, {})

View file

@ -1,5 +1,4 @@
"""The songpal component."""
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry

View file

@ -6,9 +6,11 @@ from pyspcwebgw.area import Area
from pyspcwebgw.zone import Zone
import voluptuous as vol
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client, discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -34,7 +36,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the SPC component."""
async def async_upate_callback(spc_object):

View file

@ -4,10 +4,12 @@ import logging
from spiderpy.spiderapi import SpiderApi, SpiderApiException, UnauthorizedException
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, PLATFORMS
@ -32,7 +34,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up a config entry."""
hass.data[DOMAIN] = {}
if DOMAIN not in config:
@ -50,7 +52,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 Spider via config entry."""
try:
api = await hass.async_add_executor_job(
@ -73,7 +75,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 Spider entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if not unload_ok:

View file

@ -18,11 +18,13 @@ from homeassistant.const import (
CONF_VERIFY_SSL,
EVENT_STATE_CHANGED,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import state as state_helper
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import FILTER_SCHEMA
from homeassistant.helpers.json import JSONEncoder
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -52,7 +54,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Splunk component."""
conf = config[DOMAIN]
host = conf.get(CONF_HOST)

View file

@ -19,7 +19,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True
async def async_unload_entry(hass, entry):
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
# Stop player discovery task for this config entry.
hass.data[DOMAIN][entry.entry_id][PLAYER_DISCOVERY_UNSUB]()

View file

@ -5,8 +5,10 @@ import statsd
import voluptuous as vol
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_PREFIX, EVENT_STATE_CHANGED
from homeassistant.core import HomeAssistant
from homeassistant.helpers import state as state_helper
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -39,7 +41,7 @@ CONFIG_SCHEMA = vol.Schema(
)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the StatsD component."""
conf = config[DOMAIN]

View file

@ -7,8 +7,10 @@ import voluptuous as vol
from homeassistant.components.modbus.const import CONF_HUB, DEFAULT_HUB, MODBUS_DOMAIN
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import Throttle
DOMAIN = "stiebel_eltron"
@ -30,7 +32,7 @@ _LOGGER = logging.getLogger(__name__)
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the STIEBEL ELTRON unit.
Will automatically load climate platform.

View file

@ -5,9 +5,10 @@ from streamlabswater import streamlabswater
import voluptuous as vol
from homeassistant.const import CONF_API_KEY, Platform
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.typing import ConfigType
DOMAIN = "streamlabswater"
@ -39,7 +40,7 @@ SET_AWAY_MODE_SCHEMA = vol.Schema(
)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the streamlabs water integration."""
conf = config[DOMAIN]

View file

@ -36,7 +36,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass, entry):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Subaru from a config entry."""
config = entry.data
websession = aiohttp_client.async_get_clientsession(hass)

View file

@ -8,13 +8,14 @@ from homeassistant.const import (
SUN_EVENT_SUNRISE,
SUN_EVENT_SUNSET,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import event
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.sun import (
get_astral_location,
get_location_astral_event_next,
)
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import dt as dt_util
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
@ -72,7 +73,7 @@ _PHASE_UPDATES = {
}
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track the state of the sun."""
if config.get(CONF_ELEVATION) is not None:
_LOGGER.warning(

View file

@ -9,9 +9,11 @@ from asyncpysupla import SuplaAPI
import voluptuous as vol
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
@ -51,7 +53,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, base_config):
async def async_setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
"""Set up the Supla component."""
server_confs = base_config[DOMAIN][CONF_SERVERS]

View file

@ -10,8 +10,9 @@ import voluptuous as vol
from homeassistant import __path__ as HOMEASSISTANT_PATH
from homeassistant.components.http import HomeAssistantView
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import ServiceCall, callback
from homeassistant.core import HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
CONF_MAX_ENTRIES = "max_entries"
CONF_FIRE_EVENT = "fire_event"
@ -194,7 +195,7 @@ class LogErrorHandler(logging.Handler):
self.hass.bus.fire(EVENT_SYSTEM_LOG, entry.to_dict())
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the logger component."""
if (conf := config.get(DOMAIN)) is None:
conf = CONFIG_SCHEMA({DOMAIN: {}})[DOMAIN]