Add init type hints [v-z] (#63195)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/63224/head
epenet 2022-01-02 16:27:12 +01:00 committed by GitHub
parent 6d51cccbf7
commit e7b262f9e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 55 additions and 30 deletions

View File

@ -33,6 +33,7 @@ from homeassistant.helpers.entity import (
) )
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
@ -92,7 +93,7 @@ def is_on(hass, entity_id):
return hass.states.is_state(entity_id, STATE_ON) return hass.states.is_state(entity_id, STATE_ON)
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the vacuum component.""" """Set up the vacuum component."""
component = hass.data[DOMAIN] = EntityComponent( component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL _LOGGER, DOMAIN, hass, SCAN_INTERVAL

View File

@ -10,10 +10,11 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
from homeassistant.core import ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
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.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
DOMAIN = "velux" DOMAIN = "velux"
DATA_VELUX = "data_velux" DATA_VELUX = "data_velux"
@ -30,7 +31,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the velux component.""" """Set up the velux component."""
try: try:
hass.data[DATA_VELUX] = VeluxModule(hass, config[DOMAIN]) hass.data[DATA_VELUX] = VeluxModule(hass, config[DOMAIN])

View File

@ -25,7 +25,7 @@ from .const import _LOGGER, DOMAIN, VENSTAR_SLEEP, VENSTAR_TIMEOUT
PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.SENSOR] PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.SENSOR]
async def async_setup_entry(hass, config): async def async_setup_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
"""Set up the Venstar thermostat.""" """Set up the Venstar thermostat."""
username = config.data.get(CONF_USERNAME) username = config.data.get(CONF_USERNAME)
password = config.data.get(CONF_PASSWORD) password = config.data.get(CONF_PASSWORD)
@ -55,7 +55,7 @@ async def async_setup_entry(hass, config):
return True return True
async def async_unload_entry(hass, config): async def async_unload_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
"""Unload the config config and platforms.""" """Unload the config config and platforms."""
unload_ok = await hass.config_entries.async_unload_platforms(config, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(config, PLATFORMS)
if unload_ok: if unload_ok:

View File

@ -5,9 +5,11 @@ import pyversasense as pyv
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 aiohttp_client from homeassistant.helpers import aiohttp_client
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
from .const import ( from .const import (
KEY_CONSUMER, KEY_CONSUMER,
@ -30,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 versasense component.""" """Set up the versasense component."""
session = aiohttp_client.async_get_clientsession(hass) session = aiohttp_client.async_get_clientsession(hass)
consumer = pyv.Consumer(config[DOMAIN]["host"], session) consumer = pyv.Consumer(config[DOMAIN]["host"], session)

View File

@ -3,8 +3,9 @@ import logging
from pyvesync import VeSync from pyvesync import VeSync
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, 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
@ -27,7 +28,7 @@ _LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False) CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
async def async_setup_entry(hass, config_entry): async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Set up Vesync as config entry.""" """Set up Vesync as config entry."""
username = config_entry.data[CONF_USERNAME] username = config_entry.data[CONF_USERNAME]
password = config_entry.data[CONF_PASSWORD] password = config_entry.data[CONF_PASSWORD]
@ -116,7 +117,7 @@ async def async_setup_entry(hass, config_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)
if unload_ok: if unload_ok:

View File

@ -20,6 +20,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.storage import STORAGE_DIR from homeassistant.helpers.storage import STORAGE_DIR
from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
CONF_CIRCUIT, CONF_CIRCUIT,
@ -71,7 +72,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass: HomeAssistant, config) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the ViCare component from yaml.""" """Set up the ViCare component from yaml."""
if DOMAIN not in config: if DOMAIN not in config:
# Setup via UI. No need to continue yaml-based setup # Setup via UI. No need to continue yaml-based setup

View File

@ -13,6 +13,7 @@ from homeassistant.const import (
CONF_SCAN_INTERVAL, CONF_SCAN_INTERVAL,
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
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
@ -22,6 +23,7 @@ from homeassistant.helpers.dispatcher import (
) )
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
DOMAIN = "volvooncall" DOMAIN = "volvooncall"
@ -114,7 +116,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Volvo On Call component.""" """Set up the Volvo On Call component."""
session = async_get_clientsession(hass) session = async_get_clientsession(hass)

View File

@ -6,7 +6,9 @@ import voluptuous as vol
from vultr import Vultr as VultrAPI from vultr import Vultr as VultrAPI
from homeassistant.const import CONF_API_KEY, Platform from homeassistant.const import CONF_API_KEY, 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__)
@ -44,7 +46,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Vultr component.""" """Set up the Vultr component."""
api_key = config[DOMAIN].get(CONF_API_KEY) api_key = config[DOMAIN].get(CONF_API_KEY)

View File

@ -9,8 +9,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import dispatcher_send from homeassistant.helpers.dispatcher import dispatcher_send
from homeassistant.helpers.typing import ConfigType
DATA_W800RF32 = "data_w800rf32" DATA_W800RF32 = "data_w800rf32"
DOMAIN = "w800rf32" DOMAIN = "w800rf32"
@ -24,7 +26,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the w800rf32 component.""" """Set up the w800rf32 component."""
# Declare the Handle event # Declare the Handle event

View File

@ -31,6 +31,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
from homeassistant.helpers.entity import Entity, EntityDescription from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.temperature import display_temp as show_temp from homeassistant.helpers.temperature import display_temp as show_temp
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.temperature import convert as convert_temperature from homeassistant.util.temperature import convert as convert_temperature
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
@ -96,7 +97,7 @@ SET_OPERATION_MODE_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up water_heater devices.""" """Set up water_heater devices."""
component = hass.data[DOMAIN] = EntityComponent( component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL _LOGGER, DOMAIN, hass, SCAN_INTERVAL

View File

@ -21,9 +21,10 @@ from homeassistant.const import (
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
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__)
@ -68,7 +69,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Watson IoT Platform component.""" """Set up the Watson IoT Platform component."""
conf = config[DOMAIN] conf = config[DOMAIN]

View File

@ -16,6 +16,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
from homeassistant.helpers.entity import Entity, EntityDescription from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.temperature import display_temp as show_temp from homeassistant.helpers.temperature import display_temp as show_temp
from homeassistant.helpers.typing import ConfigType
# mypy: allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-defs, no-check-untyped-defs
@ -78,7 +79,7 @@ class Forecast(TypedDict, total=False):
wind_speed: float | None wind_speed: float | None
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the weather component.""" """Set up the weather component."""
component = hass.data[DOMAIN] = EntityComponent( component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL _LOGGER, DOMAIN, hass, SCAN_INTERVAL

View File

@ -19,9 +19,10 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
EVENT_HOMEASSISTANT_STOP, 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.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
ATTR_BUTTON, ATTR_BUTTON,
@ -83,7 +84,7 @@ SERVICE_TO_METHOD = {
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the LG WebOS TV platform.""" """Set up the LG WebOS TV platform."""
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}

View File

@ -15,9 +15,11 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
) )
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import dispatcher_send from homeassistant.helpers.dispatcher import dispatcher_send
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__)
@ -124,7 +126,7 @@ class WirelessTagPlatform:
self.api.start_monitoring(push_callback) self.api.start_monitoring(push_callback)
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Wireless Sensor Tag component.""" """Set up the Wireless Sensor Tag component."""
conf = config[DOMAIN] conf = config[DOMAIN]
username = conf.get(CONF_USERNAME) username = conf.get(CONF_USERNAME)

View File

@ -18,9 +18,11 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
PERCENTAGE, PERCENTAGE,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN from .const import DOMAIN
@ -58,7 +60,7 @@ PLATFORM_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the connection to the XBee Zigbee device.""" """Set up the connection to the XBee Zigbee device."""
usb_device = config[DOMAIN].get(CONF_DEVICE, DEFAULT_DEVICE) usb_device = config[DOMAIN].get(CONF_DEVICE, DEFAULT_DEVICE)
baud = int(config[DOMAIN].get(CONF_BAUD, DEFAULT_BAUD)) baud = int(config[DOMAIN].get(CONF_BAUD, DEFAULT_BAUD))

View File

@ -17,12 +17,13 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
from homeassistant.core import ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
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.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from .const import ( from .const import (
@ -74,7 +75,7 @@ SERVICE_SCHEMA_REMOVE_DEVICE = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Xiaomi component.""" """Set up the Xiaomi component."""
def play_ringtone_service(call: ServiceCall) -> None: def play_ringtone_service(call: ServiceCall) -> None:

View File

@ -13,9 +13,11 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
Platform, Platform,
) )
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.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -47,7 +49,7 @@ PLATFORMS = [Platform.CLIMATE, Platform.SENSOR, Platform.SWITCH]
UPDATE_LOCK = asyncio.Lock() UPDATE_LOCK = asyncio.Lock()
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up XS1 integration.""" """Set up XS1 integration."""
_LOGGER.debug("Initializing XS1") _LOGGER.debug("Initializing XS1")

View File

@ -1,15 +1,15 @@
"""Zerproc lights integration.""" """Zerproc lights integration."""
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import Platform from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN
PLATFORMS = [Platform.LIGHT] PLATFORMS = [Platform.LIGHT]
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Zerproc platform.""" """Set up the Zerproc platform."""
hass.async_create_task( hass.async_create_task(
hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_IMPORT}) hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_IMPORT})

View File

@ -72,7 +72,7 @@ CENTICELSIUS = "C-100"
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: ConfigType): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up ZHA from config.""" """Set up ZHA from config."""
hass.data[DATA_ZHA] = {} hass.data[DATA_ZHA] = {}

View File

@ -14,9 +14,10 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
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.discovery import async_load_platform from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -51,7 +52,7 @@ SET_RUN_STATE_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the ZoneMinder component.""" """Set up the ZoneMinder component."""
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}

View File

@ -37,6 +37,7 @@ from homeassistant.helpers.entity_registry import (
) )
from homeassistant.helpers.entity_values import EntityValues from homeassistant.helpers.entity_values import EntityValues
from homeassistant.helpers.event import async_track_time_change from homeassistant.helpers.event import async_track_time_change
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import convert from homeassistant.util import convert
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -318,7 +319,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
return True return True
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Z-Wave components.""" """Set up Z-Wave components."""
if DOMAIN not in config: if DOMAIN not in config:
return True return True