Add setup type hints [i-k] (#63444)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
fee95e129a
commit
178d2848f3
6 changed files with 52 additions and 22 deletions
|
@ -1,4 +1,6 @@
|
|||
"""Component for interfacing RFK101 proximity card readers."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from rfk101py.rfk101py import rfk101py
|
||||
|
@ -10,7 +12,9 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -37,7 +41,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the IDTECK proximity card component."""
|
||||
conf = config[DOMAIN]
|
||||
for unit in conf:
|
||||
|
@ -78,7 +82,7 @@ class IdteckReader:
|
|||
EVENT_IDTECK_PROX_KEYCARD, {"card": card, "name": self._name}
|
||||
)
|
||||
|
||||
def stop(self):
|
||||
def stop(self, _: Event) -> None:
|
||||
"""Close resources."""
|
||||
if self._connection:
|
||||
self._connection.close()
|
||||
|
|
|
@ -22,6 +22,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
ATTR_CONTROLLER_ID,
|
||||
|
@ -224,9 +225,9 @@ PULSE_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the IHC integration."""
|
||||
conf = config.get(DOMAIN)
|
||||
conf = config[DOMAIN]
|
||||
for index, controller_conf in enumerate(conf):
|
||||
if not ihc_setup(hass, config, controller_conf, index):
|
||||
return False
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Numeric integration of data coming from a source sensor over time."""
|
||||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal, DecimalException
|
||||
import logging
|
||||
|
||||
|
@ -22,10 +24,12 @@ from homeassistant.const import (
|
|||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||
|
||||
|
@ -77,7 +81,12 @@ PLATFORM_SCHEMA = vol.All(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the integration sensor."""
|
||||
integral = IntegrationSensor(
|
||||
config[CONF_SOURCE_SENSOR],
|
||||
|
@ -97,14 +106,14 @@ class IntegrationSensor(RestoreEntity, SensorEntity):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
source_entity,
|
||||
name,
|
||||
round_digits,
|
||||
unit_prefix,
|
||||
unit_time,
|
||||
unit_of_measurement,
|
||||
integration_method,
|
||||
):
|
||||
source_entity: str,
|
||||
name: str | None,
|
||||
round_digits: int,
|
||||
unit_prefix: str | None,
|
||||
unit_time: str,
|
||||
unit_of_measurement: str | None,
|
||||
integration_method: str,
|
||||
) -> None:
|
||||
"""Initialize the integration sensor."""
|
||||
self._sensor_source_id = source_entity
|
||||
self._round_digits = round_digits
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Native Home Assistant iOS app component."""
|
||||
import datetime
|
||||
from http import HTTPStatus
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -11,6 +12,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv, discovery
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util.json import load_json, save_json
|
||||
|
||||
from .const import (
|
||||
|
@ -247,7 +249,7 @@ def device_name_for_push_id(hass, push_id):
|
|||
return None
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the iOS component."""
|
||||
conf = config.get(DOMAIN)
|
||||
|
||||
|
@ -255,6 +257,9 @@ async def async_setup(hass, config):
|
|||
load_json, hass.config.path(CONFIGURATION_FILE)
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(ios_config, dict)
|
||||
|
||||
if ios_config == {}:
|
||||
ios_config[ATTR_DEVICES] = {}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for iTach IR devices."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import pyitachip2ir
|
||||
|
@ -18,7 +20,10 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
DEVICE_DEFAULT_NAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -63,18 +68,23 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the ITach connection and devices."""
|
||||
itachip2ir = pyitachip2ir.ITachIP2IR(
|
||||
config.get(CONF_MAC), config.get(CONF_HOST), int(config.get(CONF_PORT))
|
||||
config.get(CONF_MAC), config[CONF_HOST], int(config[CONF_PORT])
|
||||
)
|
||||
|
||||
if not itachip2ir.ready(CONNECT_TIMEOUT):
|
||||
_LOGGER.error("Unable to find iTach")
|
||||
return False
|
||||
return
|
||||
|
||||
devices = []
|
||||
for data in config.get(CONF_DEVICES):
|
||||
for data in config[CONF_DEVICES]:
|
||||
name = data.get(CONF_NAME)
|
||||
modaddr = int(data.get(CONF_MODADDR, DEFAULT_MODADDR))
|
||||
connaddr = int(data.get(CONF_CONNADDR, DEFAULT_CONNADDR))
|
||||
|
@ -91,7 +101,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
itachip2ir.addDevice(name, modaddr, connaddr, cmddatas)
|
||||
devices.append(ITachIP2IRRemote(itachip2ir, name, ir_count))
|
||||
add_entities(devices, True)
|
||||
return True
|
||||
|
||||
|
||||
class ITachIP2IRRemote(remote.RemoteEntity):
|
||||
|
|
|
@ -10,7 +10,9 @@ from evdev import InputDevice, categorize, ecodes, list_devices
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -60,9 +62,9 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the keyboard_remote."""
|
||||
config = config.get(DOMAIN)
|
||||
config = config[DOMAIN]
|
||||
|
||||
remote = KeyboardRemote(hass, config)
|
||||
remote.setup()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue