Add init type hints [n-o] (#63190)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-01 22:39:38 +01:00 committed by GitHub
parent d57c54c93e
commit b6909feb8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 55 additions and 34 deletions

View File

@ -6,9 +6,11 @@ import defusedxml.ElementTree as ET
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_DOMAIN, CONF_HOST, CONF_PASSWORD from homeassistant.const import CONF_DOMAIN, CONF_HOST, CONF_PASSWORD
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
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -32,7 +34,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Initialize the namecheap DNS component.""" """Initialize the namecheap DNS component."""
host = config[DOMAIN][CONF_HOST] host = config[DOMAIN][CONF_HOST]
domain = config[DOMAIN][CONF_DOMAIN] domain = config[DOMAIN][CONF_DOMAIN]

View File

@ -16,10 +16,11 @@ from homeassistant.const import (
CONF_SCAN_INTERVAL, CONF_SCAN_INTERVAL,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
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.discovery import async_load_platform from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
DOMAIN = "ness_alarm" DOMAIN = "ness_alarm"
DATA_NESS = "ness_alarm" DATA_NESS = "ness_alarm"
@ -84,7 +85,7 @@ SERVICE_SCHEMA_AUX = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Ness Alarm platform.""" """Set up the Ness Alarm platform."""
conf = config[DOMAIN] conf = config[DOMAIN]

View File

@ -19,7 +19,7 @@ from homeassistant.const import (
CONF_RECIPIENT, CONF_RECIPIENT,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
from homeassistant.core import ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
@ -28,6 +28,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_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType
from . import sensor_types from . import sensor_types
@ -171,7 +172,7 @@ class LTEData:
return next(iter(self.modem_data.values())) return next(iter(self.modem_data.values()))
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Netgear LTE component.""" """Set up Netgear LTE component."""
if DATA_KEY not in hass.data: if DATA_KEY not in hass.data:
websession = async_create_clientsession( websession = async_create_clientsession(

View File

@ -12,8 +12,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.event import track_time_interval from homeassistant.helpers.event import track_time_interval
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -90,7 +92,7 @@ SENSORS = (
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Nextcloud integration.""" """Set up the Nextcloud integration."""
# Fetch Nextcloud Monitor api data # Fetch Nextcloud Monitor api data
conf = config[DOMAIN] conf = config[DOMAIN]

View File

@ -2,8 +2,10 @@
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_TOKEN from homeassistant.const import CONF_TOKEN
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
from .const import DOMAIN from .const import DOMAIN
@ -12,7 +14,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the notify_events component.""" """Set up the notify_events component."""
hass.data[DOMAIN] = config[DOMAIN] hass.data[DOMAIN] = config[DOMAIN]

View File

@ -7,6 +7,8 @@ import logging
from nsw_fuel import FuelCheckClient, FuelCheckError, Station from nsw_fuel import FuelCheckClient, FuelCheckError, Station
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import DATA_NSW_FUEL_STATION from .const import DATA_NSW_FUEL_STATION
@ -17,7 +19,7 @@ DOMAIN = "nsw_fuel_station"
SCAN_INTERVAL = datetime.timedelta(hours=1) SCAN_INTERVAL = datetime.timedelta(hours=1)
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the NSW Fuel Station platform.""" """Set up the NSW Fuel Station platform."""
client = FuelCheckClient() client = FuelCheckClient()

View File

@ -1,5 +1,4 @@
"""The nuki component.""" """The nuki component."""
from datetime import timedelta from datetime import timedelta
import logging import logging
@ -9,7 +8,9 @@ from pynuki.bridge import InvalidCredentialsException
from requests.exceptions import RequestException from requests.exceptions import RequestException
from homeassistant import exceptions from homeassistant import exceptions
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN, Platform from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -49,7 +50,7 @@ def _update_devices(devices):
break break
async def async_setup_entry(hass, entry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up the Nuki entry.""" """Set up the Nuki entry."""
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
@ -115,7 +116,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 the Nuki entry.""" """Unload the Nuki 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

@ -14,8 +14,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
PERCENTAGE, PERCENTAGE,
) )
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
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -117,7 +119,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Initialize the numato integration. """Initialize the numato integration.
Discovers available Numato devices and loads the binary_sensor, sensor and Discovers available Numato devices and loads the binary_sensor, sensor and

View File

@ -24,6 +24,7 @@ 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.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util import slugify as util_slugify from homeassistant.util import slugify as util_slugify
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -122,7 +123,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass: HomeAssistant, config: dict): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the OctoPrint component.""" """Set up the OctoPrint component."""
if DOMAIN not in config: if DOMAIN not in config:
return True return True
@ -147,7 +148,7 @@ async def async_setup(hass: HomeAssistant, config: dict):
return True return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up OctoPrint from a config entry.""" """Set up OctoPrint from a config entry."""
if DOMAIN not in hass.data: if DOMAIN not in hass.data:
@ -175,7 +176,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
return True return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): 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,9 @@ from homeassistant.const import (
CONF_SSL, CONF_SSL,
CONF_USERNAME, CONF_USERNAME,
) )
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 .const import ( from .const import (
ATTR_SEASON, ATTR_SEASON,
@ -74,7 +75,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Ombi component platform.""" """Set up the Ombi component platform."""
ombi = pyombi.Ombi( ombi = pyombi.Ombi(

View File

@ -1,6 +1,7 @@
"""Support to help onboard new users.""" """Support to help onboard new users."""
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.storage import Store from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
from . import views from . import views
@ -47,7 +48,7 @@ def async_is_user_onboarded(hass):
return async_is_onboarded(hass) or STEP_USER in hass.data[DOMAIN]["done"] return async_is_onboarded(hass) or STEP_USER in hass.data[DOMAIN]["done"]
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the onboarding component.""" """Set up the onboarding component."""
store = OnboadingStorage(hass, STORAGE_VERSION, STORAGE_KEY, private=True) store = OnboadingStorage(hass, STORAGE_VERSION, STORAGE_KEY, private=True)
if (data := await store.async_load()) is None: if (data := await store.async_load()) is None:

View File

@ -6,7 +6,7 @@ import pyotgw
import pyotgw.vars as gw_vars import pyotgw.vars as gw_vars
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 (
ATTR_DATE, ATTR_DATE,
ATTR_ID, ATTR_ID,
@ -22,12 +22,13 @@ from homeassistant.const import (
PRECISION_WHOLE, PRECISION_WHOLE,
Platform, Platform,
) )
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.device_registry import ( from homeassistant.helpers.device_registry import (
async_get_registry as async_get_dev_reg, async_get_registry as async_get_dev_reg,
) )
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_CH_OVRD, ATTR_CH_OVRD,
@ -88,7 +89,7 @@ async def options_updated(hass, entry):
async_dispatcher_send(hass, gateway.options_update_signal, entry) async_dispatcher_send(hass, gateway.options_update_signal, entry)
async def async_setup_entry(hass, config_entry): async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Set up the OpenTherm Gateway component.""" """Set up the OpenTherm Gateway component."""
if DATA_OPENTHERM_GW not in hass.data: if DATA_OPENTHERM_GW not in hass.data:
hass.data[DATA_OPENTHERM_GW] = {DATA_GATEWAYS: {}} hass.data[DATA_OPENTHERM_GW] = {DATA_GATEWAYS: {}}
@ -118,7 +119,7 @@ async def async_setup_entry(hass, config_entry):
return True return True
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the OpenTherm Gateway component.""" """Set up the OpenTherm Gateway component."""
if not hass.config_entries.async_entries(DOMAIN) and DOMAIN in config: if not hass.config_entries.async_entries(DOMAIN) and DOMAIN in config:
conf = config[DOMAIN] conf = config[DOMAIN]
@ -396,7 +397,7 @@ def register_services(hass):
) )
async def async_unload_entry(hass, entry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Cleanup and disconnect from gateway.""" """Cleanup and disconnect from gateway."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
gateway = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][entry.data[CONF_ID]] gateway = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][entry.data[CONF_ID]]

View File

@ -6,8 +6,10 @@ from pyopnsense.exceptions import APIException
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
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
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -36,7 +38,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
def setup(hass, config): def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the opnsense component.""" """Set up the opnsense component."""
conf = config[DOMAIN] conf = config[DOMAIN]

View File

@ -1,10 +1,11 @@
"""Support for controlling GPIO pins of a Orange Pi.""" """Support for controlling GPIO pins of a Orange Pi."""
import logging import logging
from OPi import GPIO from OPi import GPIO
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
from .const import PIN_MODES from .const import PIN_MODES
@ -13,7 +14,7 @@ _LOGGER = logging.getLogger(__name__)
DOMAIN = "orangepi_gpio" DOMAIN = "orangepi_gpio"
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Orange Pi GPIO component.""" """Set up the Orange Pi GPIO component."""
def cleanup_gpio(event): def cleanup_gpio(event):

View File

@ -15,7 +15,6 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -83,7 +82,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigType) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload OVO Energy config entry.""" """Unload OVO Energy config entry."""
# Unload sensors # Unload sensors
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -9,6 +9,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import mqtt from homeassistant.components import mqtt
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_GPS_ACCURACY, ATTR_GPS_ACCURACY,
ATTR_LATITUDE, ATTR_LATITUDE,
@ -16,8 +17,9 @@ from homeassistant.const import (
CONF_WEBHOOK_ID, CONF_WEBHOOK_ID,
Platform, Platform,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.setup import async_when_setup from homeassistant.setup import async_when_setup
from .config_flow import CONF_SECRET from .config_flow import CONF_SECRET
@ -58,7 +60,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass, config): async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Initialize OwnTracks component.""" """Initialize OwnTracks component."""
hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None} hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None}
if not hass.config_entries.async_entries(DOMAIN): if not hass.config_entries.async_entries(DOMAIN):
@ -71,7 +73,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 OwnTracks entry.""" """Set up OwnTracks entry."""
config = hass.data[DOMAIN]["config"] config = hass.data[DOMAIN]["config"]
max_gps_accuracy = config.get(CONF_MAX_GPS_ACCURACY) max_gps_accuracy = config.get(CONF_MAX_GPS_ACCURACY)
@ -112,7 +114,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 an OwnTracks config entry.""" """Unload an OwnTracks config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
@ -121,7 +123,7 @@ async def async_unload_entry(hass, entry):
return unload_ok return unload_ok
async def async_remove_entry(hass, entry): async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Remove an OwnTracks config entry.""" """Remove an OwnTracks config entry."""
if not entry.data.get("cloudhook"): if not entry.data.get("cloudhook"):
return return