From b168a8c7d0fe541e4b207d1576c0847a946cce72 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 5 Jan 2022 14:56:34 +0100 Subject: [PATCH] Use imports from `helpers.typing` (#63459) --- homeassistant/components/airthings/sensor.py | 2 +- homeassistant/components/iotawatt/sensor.py | 5 +++-- homeassistant/components/mqtt/__init__.py | 8 ++++---- homeassistant/components/rainforest_eagle/sensor.py | 2 +- homeassistant/components/sensibo/climate.py | 7 ++----- .../components/trafikverket_weatherstation/sensor.py | 7 ++----- .../components/yale_smart_alarm/alarm_control_panel.py | 7 ++----- 7 files changed, 15 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/airthings/sensor.py b/homeassistant/components/airthings/sensor.py index a753a0b213f..028ea67916a 100644 --- a/homeassistant/components/airthings/sensor.py +++ b/homeassistant/components/airthings/sensor.py @@ -8,7 +8,6 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, SensorStateClass, - StateType, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -23,6 +22,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, diff --git a/homeassistant/components/iotawatt/sensor.py b/homeassistant/components/iotawatt/sensor.py index e2a453e6453..62f65741566 100644 --- a/homeassistant/components/iotawatt/sensor.py +++ b/homeassistant/components/iotawatt/sensor.py @@ -28,6 +28,7 @@ from homeassistant.helpers import entity, entity_registry, update_coordinator from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity +from homeassistant.helpers.typing import StateType from homeassistant.util import dt from .const import ( @@ -221,7 +222,7 @@ class IotaWattSensor(update_coordinator.CoordinatorEntity, SensorEntity): return attrs @property - def native_value(self) -> entity.StateType: + def native_value(self) -> StateType: """Return the state of the sensor.""" if func := self.entity_description.value: return func(self._sensor_data.getValue()) @@ -258,7 +259,7 @@ class IotaWattAccumulatingSensor(IotaWattSensor, RestoreEntity): super()._handle_coordinator_update() @property - def native_value(self) -> entity.StateType: + def native_value(self) -> StateType: """Return the state of the sensor.""" if self._accumulated_value is None: return None diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 1265cfd7b4b..5a17cf95cf5 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -51,7 +51,7 @@ from homeassistant.helpers import config_validation as cv, event, template from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send from homeassistant.helpers.entity import Entity from homeassistant.helpers.frame import report -from homeassistant.helpers.typing import ConfigType, ServiceDataType +from homeassistant.helpers.typing import ConfigType, ServiceDataType, TemplateVarsType from homeassistant.loader import bind_hass from homeassistant.util import dt as dt_util from homeassistant.util.async_ import run_callback_threadsafe @@ -286,7 +286,7 @@ class MqttCommandTemplate: def async_render( self, value: PublishPayloadType = None, - variables: template.TemplateVarsType = None, + variables: TemplateVarsType = None, ) -> PublishPayloadType: """Render or convert the command template with given value or variables.""" @@ -328,7 +328,7 @@ class MqttValueTemplate: *, hass: HomeAssistant | None = None, entity: Entity | None = None, - config_attributes: template.TemplateVarsType = None, + config_attributes: TemplateVarsType = None, ) -> None: """Instantiate a value template.""" self._value_template = value_template @@ -347,7 +347,7 @@ class MqttValueTemplate: self, payload: ReceivePayloadType, default: ReceivePayloadType | object = _SENTINEL, - variables: template.TemplateVarsType = None, + variables: TemplateVarsType = None, ) -> ReceivePayloadType: """Render with possible json value or pass-though a received MQTT value.""" if self._value_template is None: diff --git a/homeassistant/components/rainforest_eagle/sensor.py b/homeassistant/components/rainforest_eagle/sensor.py index 0f2c4f62125..8f59888603c 100644 --- a/homeassistant/components/rainforest_eagle/sensor.py +++ b/homeassistant/components/rainforest_eagle/sensor.py @@ -6,13 +6,13 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, SensorStateClass, - StateType, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DOMAIN diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index b90def180d8..e15b1a4e940 100644 --- a/homeassistant/components/sensibo/climate.py +++ b/homeassistant/components/sensibo/climate.py @@ -39,11 +39,8 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import config_validation as cv from homeassistant.helpers.entity import DeviceInfo -from homeassistant.helpers.entity_platform import ( - AddEntitiesCallback, - ConfigType, - DiscoveryInfoType, -) +from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util.temperature import convert as convert_temperature from .const import _FETCH_FIELDS, ALL, DOMAIN, TIMEOUT diff --git a/homeassistant/components/trafikverket_weatherstation/sensor.py b/homeassistant/components/trafikverket_weatherstation/sensor.py index e564002c61c..753a300c96b 100644 --- a/homeassistant/components/trafikverket_weatherstation/sensor.py +++ b/homeassistant/components/trafikverket_weatherstation/sensor.py @@ -33,11 +33,8 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity_platform import ( - AddEntitiesCallback, - ConfigType, - DiscoveryInfoType, -) +from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util import Throttle from .const import ATTR_ACTIVE, ATTR_MEASURE_TIME, ATTRIBUTION, CONF_STATION, DOMAIN diff --git a/homeassistant/components/yale_smart_alarm/alarm_control_panel.py b/homeassistant/components/yale_smart_alarm/alarm_control_panel.py index 4011e7dfbdc..d9106031345 100644 --- a/homeassistant/components/yale_smart_alarm/alarm_control_panel.py +++ b/homeassistant/components/yale_smart_alarm/alarm_control_panel.py @@ -16,11 +16,8 @@ from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import DeviceInfo -from homeassistant.helpers.entity_platform import ( - AddEntitiesCallback, - ConfigType, - DiscoveryInfoType, -) +from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import (