Add init type hints [t-u] (#63194)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-02 07:06:11 +01:00 committed by GitHub
parent 06b9be4d9c
commit 18056f3a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 57 additions and 36 deletions

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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, {})

View file

@ -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()

View file

@ -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)

View file

@ -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)

View file

@ -1,5 +1,4 @@
"""Support for Toon van Eneco devices."""
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry

View file

@ -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:

View file

@ -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(

View file

@ -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)()

View file

@ -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)

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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, {})