Improve met_eireann generic typing (#98278)
parent
ff0566b11f
commit
78ac36e3fe
|
@ -1,6 +1,7 @@
|
|||
"""The met_eireann component."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Self
|
||||
|
||||
import meteireann
|
||||
|
||||
|
@ -33,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
|
||||
weather_data = MetEireannWeatherData(hass, config_entry.data, raw_weather_data)
|
||||
|
||||
async def _async_update_data():
|
||||
async def _async_update_data() -> MetEireannWeatherData:
|
||||
"""Fetch data from Met Éireann."""
|
||||
try:
|
||||
return await weather_data.fetch_data()
|
||||
|
@ -78,7 +79,7 @@ class MetEireannWeatherData:
|
|||
self.daily_forecast = None
|
||||
self.hourly_forecast = None
|
||||
|
||||
async def fetch_data(self):
|
||||
async def fetch_data(self) -> Self:
|
||||
"""Fetch data from API - (current weather and forecast)."""
|
||||
await self._weather_data.fetching_data()
|
||||
self.current_weather_data = self._weather_data.get_current_weather()
|
||||
|
|
|
@ -22,9 +22,13 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import MetEireannWeatherData
|
||||
from .const import CONDITION_MAP, DEFAULT_NAME, DOMAIN, FORECAST_MAP
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -54,7 +58,9 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class MetEireannWeather(CoordinatorEntity, WeatherEntity):
|
||||
class MetEireannWeather(
|
||||
CoordinatorEntity[DataUpdateCoordinator[MetEireannWeatherData]], WeatherEntity
|
||||
):
|
||||
"""Implementation of a Met Éireann weather condition."""
|
||||
|
||||
_attr_attribution = "Data provided by Met Éireann"
|
||||
|
|
Loading…
Reference in New Issue