Improve tankerkoenig generic coordinator typing (#116560)

This commit is contained in:
Marc Mueller 2024-05-01 22:33:07 +02:00 committed by GitHub
parent fa920fd910
commit bd24ce8d4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ _LOGGER = logging.getLogger(__name__)
TankerkoenigConfigEntry = ConfigEntry["TankerkoenigDataUpdateCoordinator"] TankerkoenigConfigEntry = ConfigEntry["TankerkoenigDataUpdateCoordinator"]
class TankerkoenigDataUpdateCoordinator(DataUpdateCoordinator): class TankerkoenigDataUpdateCoordinator(DataUpdateCoordinator[dict[str, PriceInfo]]):
"""Get the latest data from the API.""" """Get the latest data from the API."""
config_entry: TankerkoenigConfigEntry config_entry: TankerkoenigConfigEntry

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import logging import logging
from aiotankerkoenig import GasType, PriceInfo, Station from aiotankerkoenig import GasType, Station
from homeassistant.components.sensor import SensorEntity, SensorStateClass from homeassistant.components.sensor import SensorEntity, SensorStateClass
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, CURRENCY_EURO from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, CURRENCY_EURO
@ -109,5 +109,5 @@ class FuelPriceSensor(TankerkoenigCoordinatorEntity, SensorEntity):
@property @property
def native_value(self) -> float: def native_value(self) -> float:
"""Return the current price for the fuel type.""" """Return the current price for the fuel type."""
info: PriceInfo = self.coordinator.data[self._station_id] info = self.coordinator.data[self._station_id]
return getattr(info, self._fuel_type) return getattr(info, self._fuel_type)