1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

Add init type hints [misc] (#63261)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-03 12:08:14 +01:00 committed by GitHub
parent 929da2154a
commit e5ba34b9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 40 additions and 18 deletions

View File

@ -33,6 +33,7 @@ from homeassistant.helpers import (
network,
storage,
)
from homeassistant.helpers.typing import ConfigType
from . import config_flow
from .const import DOMAIN, TYPE_LOCAL, TYPE_OAUTH2
@ -66,7 +67,7 @@ CONFIG_SCHEMA = vol.Schema(
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Almond component."""
hass.data[DOMAIN] = {}

View File

@ -13,7 +13,9 @@ from homeassistant.const import (
CONF_PROFILE_NAME,
CONF_SERVICE,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.typing import ConfigType
# Loading the config flow file will register the flow
from .const import (
@ -81,7 +83,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up AWS component."""
hass.data[DATA_HASS_CONFIG] = config

View File

@ -14,8 +14,14 @@ from homeassistant.const import (
ATTR_FRIENDLY_NAME,
EVENT_TIME_CHANGED,
)
from homeassistant.core import Event, ServiceCall, callback as async_callback
from homeassistant.core import (
Event,
HomeAssistant,
ServiceCall,
callback as async_callback,
)
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.async_ import run_callback_threadsafe
@ -123,7 +129,7 @@ def request_done(hass, request_id):
).result()
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the configurator component."""
return True

View File

@ -6,7 +6,9 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.conversation.util import create_matcher
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.helpers import dispatcher, intent
import homeassistant.helpers.config_validation as cv
@ -95,7 +97,7 @@ async def async_setup(hass, config):
return True
async def async_setup_entry(hass, config):
async def async_setup_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
"""Set up a config entry."""
try:
bot = HangoutsBot(
@ -152,7 +154,7 @@ async def async_setup_entry(hass, config):
return True
async def async_unload_entry(hass, _):
async def async_unload_entry(hass: HomeAssistant, _: ConfigEntry) -> bool:
"""Unload a config entry."""
bot = hass.data[DOMAIN].pop(CONF_BOT)
await bot.async_disconnect()

View File

@ -9,6 +9,7 @@ from homeassistant.components.device_tracker import (
from homeassistant.components.device_tracker.const import (
SCAN_INTERVAL as DEFAULT_SCAN_INTERVAL,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_EXCLUDE,
CONF_INCLUDE,
@ -16,6 +17,7 @@ from homeassistant.const import (
CONF_PREFIX,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
@ -193,7 +195,7 @@ def setup(hass, config):
return True
async def async_setup_entry(hass, entry):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up config entry."""
hass.data[DOMAIN]["apis"][entry.data[CONF_USERNAME]] = get_api(
entry.data[CONF_AUTHORIZATION]
@ -201,7 +203,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 config entry."""
try:
hass.data[DOMAIN]["apis"].pop(entry.data[CONF_USERNAME])

View File

@ -36,6 +36,7 @@ from homeassistant.const import (
)
from homeassistant.core import (
DOMAIN as HA_DOMAIN,
HomeAssistant,
ServiceCall,
callback,
split_entity_id,
@ -50,6 +51,7 @@ from homeassistant.helpers.entityfilter import (
from homeassistant.helpers.integration_platform import (
async_process_integration_platforms,
)
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
import homeassistant.util.dt as dt_util
@ -130,7 +132,7 @@ def async_log_entry(hass, name, message, domain=None, entity_id=None, context=No
hass.bus.async_fire(EVENT_LOGBOOK_ENTRY, data, context=context)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Logbook setup."""
hass.data[DOMAIN] = {}

View File

@ -11,6 +11,7 @@ from homeassistant.components.media_player.const import (
ATTR_MEDIA_TITLE,
MEDIA_TYPE_GAME,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ATTR_COMMAND,
ATTR_ENTITY_ID,
@ -22,6 +23,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant, ServiceCall, split_entity_id
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entity_registry
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import location
from homeassistant.util.json import load_json, save_json
@ -58,7 +60,7 @@ class PS4Data:
self.protocol = None
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the PS4 Component."""
hass.data[PS4_DATA] = PS4Data()
@ -69,13 +71,13 @@ 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 PS4 from a config entry."""
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
return True
async def async_unload_entry(hass, entry):
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a PS4 config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -9,8 +9,9 @@ from homeassistant import config_entries
from homeassistant.components import http, websocket_api
from homeassistant.components.http.data_validator import RequestDataValidator
from homeassistant.const import ATTR_NAME
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
from homeassistant.util.json import load_json, save_json
from .const import (
@ -61,7 +62,7 @@ SCHEMA_WEBSOCKET_CLEAR_ITEMS = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend(
)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Initialize the shopping list."""
if DOMAIN not in config:

View File

@ -5,16 +5,19 @@ import logging
import aiohttp
import tibber
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_ACCESS_TOKEN,
CONF_NAME,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import discovery
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import dt as dt_util
from .const import DATA_HASS_CONFIG, DOMAIN
@ -26,14 +29,14 @@ CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass, config):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Tibber component."""
hass.data[DATA_HASS_CONFIG] = config
return True
async def async_setup_entry(hass, entry):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
tibber_connection = tibber.Tibber(

View File

@ -23,13 +23,14 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import event as event_helper, state as state_helper
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import (
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
convert_include_exclude_filter,
)
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -65,7 +66,7 @@ CONFIG_SCHEMA = vol.Schema(
)
def setup(hass, config):
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Zabbix component."""
conf = config[DOMAIN]