Update typing 14 (#48078)
This commit is contained in:
parent
7d196abc4a
commit
dcca29ef68
73 changed files with 614 additions and 521 deletions
|
@ -1,6 +1,8 @@
|
|||
"""Support for WLED sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
from typing import Any, Callable
|
||||
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_CURRENT
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -22,7 +24,7 @@ from .const import ATTR_LED_COUNT, ATTR_MAX_POWER, CURRENT_MA, DOMAIN
|
|||
async def async_setup_entry(
|
||||
hass: HomeAssistantType,
|
||||
entry: ConfigEntry,
|
||||
async_add_entities: Callable[[List[Entity], bool], None],
|
||||
async_add_entities: Callable[[list[Entity], bool], None],
|
||||
) -> None:
|
||||
"""Set up WLED sensor based on a config entry."""
|
||||
coordinator: WLEDDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
@ -52,7 +54,7 @@ class WLEDSensor(WLEDDeviceEntity):
|
|||
icon: str,
|
||||
key: str,
|
||||
name: str,
|
||||
unit_of_measurement: Optional[str] = None,
|
||||
unit_of_measurement: str | None = None,
|
||||
) -> None:
|
||||
"""Initialize WLED sensor."""
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
|
@ -92,7 +94,7 @@ class WLEDEstimatedCurrentSensor(WLEDSensor):
|
|||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Optional[Dict[str, Any]]:
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the state attributes of the entity."""
|
||||
return {
|
||||
ATTR_LED_COUNT: self.coordinator.data.info.leds.count,
|
||||
|
@ -105,7 +107,7 @@ class WLEDEstimatedCurrentSensor(WLEDSensor):
|
|||
return self.coordinator.data.info.leds.power
|
||||
|
||||
@property
|
||||
def device_class(self) -> Optional[str]:
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this sensor."""
|
||||
return DEVICE_CLASS_CURRENT
|
||||
|
||||
|
@ -131,7 +133,7 @@ class WLEDUptimeSensor(WLEDSensor):
|
|||
return uptime.replace(microsecond=0).isoformat()
|
||||
|
||||
@property
|
||||
def device_class(self) -> Optional[str]:
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this sensor."""
|
||||
return DEVICE_CLASS_TIMESTAMP
|
||||
|
||||
|
@ -199,7 +201,7 @@ class WLEDWifiRSSISensor(WLEDSensor):
|
|||
return self.coordinator.data.info.wifi.rssi
|
||||
|
||||
@property
|
||||
def device_class(self) -> Optional[str]:
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this sensor."""
|
||||
return DEVICE_CLASS_SIGNAL_STRENGTH
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue