mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add setup type hints [c-d] (#63428)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
953a4f07fa
commit
47812575d0
@ -1,10 +1,15 @@
|
|||||||
"""Support for Coinbase sensors."""
|
"""Support for Coinbase sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
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.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
API_ACCOUNT_AMOUNT,
|
API_ACCOUNT_AMOUNT,
|
||||||
@ -38,11 +43,15 @@ DEFAULT_COIN_ICON = "mdi:cash"
|
|||||||
ATTRIBUTION = "Data provided by coinbase.com"
|
ATTRIBUTION = "Data provided by coinbase.com"
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Coinbase sensor platform."""
|
"""Set up Coinbase sensor platform."""
|
||||||
instance = hass.data[DOMAIN][config_entry.entry_id]
|
instance = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
|
||||||
entities = []
|
entities: list[SensorEntity] = []
|
||||||
|
|
||||||
provided_currencies = [
|
provided_currencies = [
|
||||||
account[API_ACCOUNT_CURRENCY]
|
account[API_ACCOUNT_CURRENCY]
|
||||||
|
@ -12,8 +12,10 @@ from homeassistant.const import (
|
|||||||
CONF_UNIQUE_ID,
|
CONF_UNIQUE_ID,
|
||||||
CONF_UNIT_OF_MEASUREMENT,
|
CONF_UNIT_OF_MEASUREMENT,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
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.typing import ConfigType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_COMPENSATION,
|
CONF_COMPENSATION,
|
||||||
@ -67,11 +69,11 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Compensation sensor."""
|
"""Set up the Compensation sensor."""
|
||||||
hass.data[DATA_COMPENSATION] = {}
|
hass.data[DATA_COMPENSATION] = {}
|
||||||
|
|
||||||
for compensation, conf in config.get(DOMAIN).items():
|
for compensation, conf in config[DOMAIN].items():
|
||||||
_LOGGER.debug("Setup %s.%s", DOMAIN, compensation)
|
_LOGGER.debug("Setup %s.%s", DOMAIN, compensation)
|
||||||
|
|
||||||
degree = conf[CONF_DEGREE]
|
degree = conf[CONF_DEGREE]
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Details about printers which are connected to CUPS."""
|
"""Details about printers which are connected to CUPS."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
@ -7,8 +9,11 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT, PERCENTAGE
|
from homeassistant.const import CONF_HOST, CONF_PORT, PERCENTAGE
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -50,7 +55,12 @@ 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 CUPS sensor."""
|
"""Set up the CUPS sensor."""
|
||||||
host = config[CONF_HOST]
|
host = config[CONF_HOST]
|
||||||
port = config[CONF_PORT]
|
port = config[CONF_PORT]
|
||||||
@ -64,7 +74,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
_LOGGER.error("Unable to connect to CUPS server: %s:%s", host, port)
|
_LOGGER.error("Unable to connect to CUPS server: %s:%s", host, port)
|
||||||
raise PlatformNotReady()
|
raise PlatformNotReady()
|
||||||
|
|
||||||
dev = []
|
dev: list[SensorEntity] = []
|
||||||
for printer in printers:
|
for printer in printers:
|
||||||
if printer not in data.printers:
|
if printer not in data.printers:
|
||||||
_LOGGER.error("Printer is not present: %s", printer)
|
_LOGGER.error("Printer is not present: %s", printer)
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
"""Support for Daikin AirBase zones."""
|
"""Support for Daikin AirBase zones."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import DOMAIN as DAIKIN_DOMAIN
|
from . import DOMAIN as DAIKIN_DOMAIN
|
||||||
|
|
||||||
@ -10,7 +16,12 @@ DAIKIN_ATTR_ADVANCED = "adv"
|
|||||||
DAIKIN_ATTR_STREAMER = "streamer"
|
DAIKIN_ATTR_STREAMER = "streamer"
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Old way of setting up the platform.
|
"""Old way of setting up the platform.
|
||||||
|
|
||||||
Can only be called when a user accidentally mentions the platform in their
|
Can only be called when a user accidentally mentions the platform in their
|
||||||
@ -18,10 +29,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
|
) -> None:
|
||||||
"""Set up Daikin climate based on config_entry."""
|
"""Set up Daikin climate based on config_entry."""
|
||||||
daikin_api = hass.data[DAIKIN_DOMAIN][entry.entry_id]
|
daikin_api = hass.data[DAIKIN_DOMAIN][entry.entry_id]
|
||||||
switches = []
|
switches: list[ToggleEntity] = []
|
||||||
if zones := daikin_api.device.zones:
|
if zones := daikin_api.device.zones:
|
||||||
switches.extend(
|
switches.extend(
|
||||||
[
|
[
|
||||||
|
@ -41,7 +41,10 @@ from homeassistant.const import (
|
|||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
UV_INDEX,
|
UV_INDEX,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -570,7 +573,12 @@ 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 Dark Sky sensor."""
|
"""Set up the Dark Sky sensor."""
|
||||||
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
|
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
|
||||||
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
|
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
|
||||||
@ -603,7 +611,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
forecast = config.get(CONF_FORECAST)
|
forecast = config.get(CONF_FORECAST)
|
||||||
forecast_hour = config.get(CONF_HOURLY_FORECAST)
|
forecast_hour = config.get(CONF_HOURLY_FORECAST)
|
||||||
sensors = []
|
sensors: list[SensorEntity] = []
|
||||||
for variable in config[CONF_MONITORED_CONDITIONS]:
|
for variable in config[CONF_MONITORED_CONDITIONS]:
|
||||||
if variable in DEPRECATED_SENSOR_TYPES:
|
if variable in DEPRECATED_SENSOR_TYPES:
|
||||||
_LOGGER.warning("Monitored condition %s is deprecated", variable)
|
_LOGGER.warning("Monitored condition %s is deprecated", variable)
|
||||||
|
@ -1,17 +1,26 @@
|
|||||||
"""Support for Dexcom sensors."""
|
"""Support for Dexcom sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME
|
from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import COORDINATOR, DOMAIN, GLUCOSE_TREND_ICON, GLUCOSE_VALUE_ICON, MG_DL
|
from .const import COORDINATOR, DOMAIN, GLUCOSE_TREND_ICON, GLUCOSE_VALUE_ICON, MG_DL
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up the Dexcom sensors."""
|
"""Set up the Dexcom sensors."""
|
||||||
coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]
|
coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]
|
||||||
username = config_entry.data[CONF_USERNAME]
|
username = config_entry.data[CONF_USERNAME]
|
||||||
unit_of_measurement = config_entry.options[CONF_UNIT_OF_MEASUREMENT]
|
unit_of_measurement = config_entry.options[CONF_UNIT_OF_MEASUREMENT]
|
||||||
sensors = []
|
sensors: list[SensorEntity] = []
|
||||||
sensors.append(DexcomGlucoseTrendSensor(coordinator, username))
|
sensors.append(DexcomGlucoseTrendSensor(coordinator, username))
|
||||||
sensors.append(DexcomGlucoseValueSensor(coordinator, username, unit_of_measurement))
|
sensors.append(DexcomGlucoseValueSensor(coordinator, username, unit_of_measurement))
|
||||||
async_add_entities(sensors, False)
|
async_add_entities(sensors, False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user