From 0d7b531285497b095fe08ba7631c3dbc41da0cee Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sun, 2 Jan 2022 16:35:23 +0100 Subject: [PATCH] Add init type hints [p-q] (#63191) Co-authored-by: epenet --- homeassistant/components/panasonic_viera/__init__.py | 10 ++++++---- homeassistant/components/panel_custom/__init__.py | 4 +++- homeassistant/components/panel_iframe/__init__.py | 4 +++- homeassistant/components/pilight/__init__.py | 5 +++-- homeassistant/components/ping/__init__.py | 4 +++- homeassistant/components/plant/__init__.py | 5 +++-- homeassistant/components/point/__init__.py | 3 ++- homeassistant/components/prometheus/__init__.py | 4 +++- homeassistant/components/python_script/__init__.py | 5 +++-- homeassistant/components/qvr_pro/__init__.py | 6 +++--- 10 files changed, 32 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/panasonic_viera/__init__.py b/homeassistant/components/panasonic_viera/__init__.py index 7448097ea2c..e03dca74fb0 100644 --- a/homeassistant/components/panasonic_viera/__init__.py +++ b/homeassistant/components/panasonic_viera/__init__.py @@ -6,7 +6,7 @@ from urllib.error import HTTPError, URLError from panasonic_viera import EncryptionRequired, Keys, RemoteControl, SOAPError 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_NAME, @@ -15,8 +15,10 @@ from homeassistant.const import ( STATE_ON, Platform, ) +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.script import Script +from homeassistant.helpers.typing import ConfigType from .const import ( ATTR_DEVICE_INFO, @@ -54,7 +56,7 @@ CONFIG_SCHEMA = vol.Schema( PLATFORMS = [Platform.MEDIA_PLAYER, Platform.REMOTE] -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up Panasonic Viera from configuration.yaml.""" if DOMAIN not in config: return True @@ -69,7 +71,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 Panasonic Viera from a config entry.""" panasonic_viera_data = hass.data.setdefault(DOMAIN, {}) @@ -112,7 +114,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 a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms( config_entry, PLATFORMS diff --git a/homeassistant/components/panel_custom/__init__.py b/homeassistant/components/panel_custom/__init__.py index 8bab4d019e6..a7b3b2e30c8 100644 --- a/homeassistant/components/panel_custom/__init__.py +++ b/homeassistant/components/panel_custom/__init__.py @@ -3,7 +3,9 @@ import logging import voluptuous as vol +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType from homeassistant.loader import bind_hass _LOGGER = logging.getLogger(__name__) @@ -124,7 +126,7 @@ async def async_register_panel( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize custom panel.""" if DOMAIN not in config: return True diff --git a/homeassistant/components/panel_iframe/__init__.py b/homeassistant/components/panel_iframe/__init__.py index 0a8d7690781..8e2a98bc980 100644 --- a/homeassistant/components/panel_iframe/__init__.py +++ b/homeassistant/components/panel_iframe/__init__.py @@ -2,7 +2,9 @@ import voluptuous as vol from homeassistant.const import CONF_ICON, CONF_URL +from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType DOMAIN = "panel_iframe" @@ -35,7 +37,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the iFrame frontend panels.""" for url_path, info in config[DOMAIN].items(): hass.components.frontend.async_register_built_in_panel( diff --git a/homeassistant/components/pilight/__init__.py b/homeassistant/components/pilight/__init__.py index 6a66f6d4dc5..38d7a3e18ea 100644 --- a/homeassistant/components/pilight/__init__.py +++ b/homeassistant/components/pilight/__init__.py @@ -16,9 +16,10 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, ) -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import track_point_in_utc_time +from homeassistant.helpers.typing import ConfigType from homeassistant.util import dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -59,7 +60,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Pilight component.""" host = config[DOMAIN][CONF_HOST] diff --git a/homeassistant/components/ping/__init__.py b/homeassistant/components/ping/__init__.py index 70b90ccd886..6349b07ca12 100644 --- a/homeassistant/components/ping/__init__.py +++ b/homeassistant/components/ping/__init__.py @@ -5,14 +5,16 @@ import logging from icmplib import SocketPermissionError, ping as icmp_ping +from homeassistant.core import HomeAssistant from homeassistant.helpers.reload import async_setup_reload_service +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, PING_PRIVS, 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.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) hass.data[DOMAIN] = { diff --git a/homeassistant/components/plant/__init__.py b/homeassistant/components/plant/__init__.py index fe5b4b2483b..37ae8422af0 100644 --- a/homeassistant/components/plant/__init__.py +++ b/homeassistant/components/plant/__init__.py @@ -21,12 +21,13 @@ from homeassistant.const import ( STATE_UNKNOWN, TEMP_CELSIUS, ) -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.event import async_track_state_change_event +from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -113,7 +114,7 @@ CONFIG_SCHEMA = vol.Schema({DOMAIN: {cv.string: PLANT_SCHEMA}}, extra=vol.ALLOW_ ENABLE_LOAD_HISTORY = False -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Plant component.""" component = EntityComponent(_LOGGER, DOMAIN, hass) diff --git a/homeassistant/components/point/__init__.py b/homeassistant/components/point/__init__.py index 9bfd70d4d8d..f6587ea774a 100644 --- a/homeassistant/components/point/__init__.py +++ b/homeassistant/components/point/__init__.py @@ -24,6 +24,7 @@ from homeassistant.helpers.dispatcher import ( ) from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType from homeassistant.util.dt import as_local, parse_datetime, utc_from_timestamp from . import config_flow @@ -57,7 +58,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Minut Point component.""" if DOMAIN not in config: return True diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index 5b72a109d44..f130aee9f29 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -35,9 +35,11 @@ from homeassistant.const import ( TEMP_CELSIUS, TEMP_FAHRENHEIT, ) +from homeassistant.core import HomeAssistant from homeassistant.helpers import entityfilter, state as state_helper import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_values import EntityValues +from homeassistant.helpers.typing import ConfigType from homeassistant.util.temperature import fahrenheit_to_celsius _LOGGER = logging.getLogger(__name__) @@ -82,7 +84,7 @@ CONFIG_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Activate Prometheus component.""" hass.http.register_view(PrometheusView(prometheus_client)) diff --git a/homeassistant/components/python_script/__init__.py b/homeassistant/components/python_script/__init__.py index 1927bee526b..d3bc2e8d31e 100644 --- a/homeassistant/components/python_script/__init__.py +++ b/homeassistant/components/python_script/__init__.py @@ -20,9 +20,10 @@ from RestrictedPython.Guards import ( import voluptuous as vol from homeassistant.const import CONF_DESCRIPTION, CONF_NAME, SERVICE_RELOAD -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.service import async_set_service_schema +from homeassistant.helpers.typing import ConfigType from homeassistant.loader import bind_hass from homeassistant.util import raise_if_invalid_filename import homeassistant.util.dt as dt_util @@ -79,7 +80,7 @@ class ScriptError(HomeAssistantError): """When a script error occurs.""" -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the Python script component.""" path = hass.config.path(FOLDER) diff --git a/homeassistant/components/qvr_pro/__init__.py b/homeassistant/components/qvr_pro/__init__.py index d3417b016c6..d80511f3def 100644 --- a/homeassistant/components/qvr_pro/__init__.py +++ b/homeassistant/components/qvr_pro/__init__.py @@ -1,5 +1,4 @@ """Support for QVR Pro NVR software by QNAP.""" - import logging from pyqvrpro import Client @@ -9,9 +8,10 @@ import voluptuous as vol from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME -from homeassistant.core import ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import load_platform +from homeassistant.helpers.typing import ConfigType from .const import ( CONF_EXCLUDE_CHANNELS, @@ -48,7 +48,7 @@ SERVICE_CHANNEL_RECORD_SCHEMA = vol.Schema( ) -def setup(hass, config): +def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the QVR Pro component.""" conf = config[DOMAIN] user = conf[CONF_USERNAME]