Use imports from helpers.typing (#63459)

This commit is contained in:
Marc Mueller 2022-01-05 14:56:34 +01:00 committed by GitHub
parent b0f72f59da
commit b168a8c7d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 23 deletions

View File

@ -8,7 +8,6 @@ from homeassistant.components.sensor import (
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass, SensorStateClass,
StateType,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -23,6 +22,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity import DeviceInfo, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,

View File

@ -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.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import StateType
from homeassistant.util import dt from homeassistant.util import dt
from .const import ( from .const import (
@ -221,7 +222,7 @@ class IotaWattSensor(update_coordinator.CoordinatorEntity, SensorEntity):
return attrs return attrs
@property @property
def native_value(self) -> entity.StateType: def native_value(self) -> StateType:
"""Return the state of the sensor.""" """Return the state of the sensor."""
if func := self.entity_description.value: if func := self.entity_description.value:
return func(self._sensor_data.getValue()) return func(self._sensor_data.getValue())
@ -258,7 +259,7 @@ class IotaWattAccumulatingSensor(IotaWattSensor, RestoreEntity):
super()._handle_coordinator_update() super()._handle_coordinator_update()
@property @property
def native_value(self) -> entity.StateType: def native_value(self) -> StateType:
"""Return the state of the sensor.""" """Return the state of the sensor."""
if self._accumulated_value is None: if self._accumulated_value is None:
return None return None

View File

@ -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.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.frame import report 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.loader import bind_hass
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from homeassistant.util.async_ import run_callback_threadsafe from homeassistant.util.async_ import run_callback_threadsafe
@ -286,7 +286,7 @@ class MqttCommandTemplate:
def async_render( def async_render(
self, self,
value: PublishPayloadType = None, value: PublishPayloadType = None,
variables: template.TemplateVarsType = None, variables: TemplateVarsType = None,
) -> PublishPayloadType: ) -> PublishPayloadType:
"""Render or convert the command template with given value or variables.""" """Render or convert the command template with given value or variables."""
@ -328,7 +328,7 @@ class MqttValueTemplate:
*, *,
hass: HomeAssistant | None = None, hass: HomeAssistant | None = None,
entity: Entity | None = None, entity: Entity | None = None,
config_attributes: template.TemplateVarsType = None, config_attributes: TemplateVarsType = None,
) -> None: ) -> None:
"""Instantiate a value template.""" """Instantiate a value template."""
self._value_template = value_template self._value_template = value_template
@ -347,7 +347,7 @@ class MqttValueTemplate:
self, self,
payload: ReceivePayloadType, payload: ReceivePayloadType,
default: ReceivePayloadType | object = _SENTINEL, default: ReceivePayloadType | object = _SENTINEL,
variables: template.TemplateVarsType = None, variables: TemplateVarsType = None,
) -> ReceivePayloadType: ) -> ReceivePayloadType:
"""Render with possible json value or pass-though a received MQTT value.""" """Render with possible json value or pass-though a received MQTT value."""
if self._value_template is None: if self._value_template is None:

View File

@ -6,13 +6,13 @@ from homeassistant.components.sensor import (
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass, SensorStateClass,
StateType,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN from .const import DOMAIN

View File

@ -39,11 +39,8 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import ( from homeassistant.helpers.entity_platform import AddEntitiesCallback
AddEntitiesCallback, from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
ConfigType,
DiscoveryInfoType,
)
from homeassistant.util.temperature import convert as convert_temperature from homeassistant.util.temperature import convert as convert_temperature
from .const import _FETCH_FIELDS, ALL, DOMAIN, TIMEOUT from .const import _FETCH_FIELDS, ALL, DOMAIN, TIMEOUT

View File

@ -33,11 +33,8 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import ( from homeassistant.helpers.entity_platform import AddEntitiesCallback
AddEntitiesCallback, from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
ConfigType,
DiscoveryInfoType,
)
from homeassistant.util import Throttle from homeassistant.util import Throttle
from .const import ATTR_ACTIVE, ATTR_MEASURE_TIME, ATTRIBUTION, CONF_STATION, DOMAIN from .const import ATTR_ACTIVE, ATTR_MEASURE_TIME, ATTRIBUTION, CONF_STATION, DOMAIN

View File

@ -16,11 +16,8 @@ from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import ( from homeassistant.helpers.entity_platform import AddEntitiesCallback
AddEntitiesCallback, from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
ConfigType,
DiscoveryInfoType,
)
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import ( from .const import (