mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Improve met_eireann generic typing (#98278)
This commit is contained in:
parent
ff0566b11f
commit
78ac36e3fe
@ -1,6 +1,7 @@
|
|||||||
"""The met_eireann component."""
|
"""The met_eireann component."""
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Self
|
||||||
|
|
||||||
import meteireann
|
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)
|
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."""
|
"""Fetch data from Met Éireann."""
|
||||||
try:
|
try:
|
||||||
return await weather_data.fetch_data()
|
return await weather_data.fetch_data()
|
||||||
@ -78,7 +79,7 @@ class MetEireannWeatherData:
|
|||||||
self.daily_forecast = None
|
self.daily_forecast = None
|
||||||
self.hourly_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)."""
|
"""Fetch data from API - (current weather and forecast)."""
|
||||||
await self._weather_data.fetching_data()
|
await self._weather_data.fetching_data()
|
||||||
self.current_weather_data = self._weather_data.get_current_weather()
|
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.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
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 homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
|
from . import MetEireannWeatherData
|
||||||
from .const import CONDITION_MAP, DEFAULT_NAME, DOMAIN, FORECAST_MAP
|
from .const import CONDITION_MAP, DEFAULT_NAME, DOMAIN, FORECAST_MAP
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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."""
|
"""Implementation of a Met Éireann weather condition."""
|
||||||
|
|
||||||
_attr_attribution = "Data provided by Met Éireann"
|
_attr_attribution = "Data provided by Met Éireann"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user