Improve energy platform typing (#117003)

This commit is contained in:
Marc Mueller 2024-05-07 18:28:42 +02:00 committed by GitHub
parent 2db64c7e6d
commit b21632ad05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,7 +8,6 @@ from collections.abc import Awaitable, Callable
from datetime import timedelta
import functools
from itertools import chain
from types import ModuleType
from typing import Any, cast
import voluptuous as vol
@ -64,13 +63,15 @@ async def async_get_energy_platforms(
@callback
def _process_energy_platform(
hass: HomeAssistant, domain: str, platform: ModuleType
hass: HomeAssistant,
domain: str,
platform: EnergyPlatform,
) -> None:
"""Process energy platforms."""
if not hasattr(platform, "async_get_solar_forecast"):
return
platforms[domain] = cast(EnergyPlatform, platform).async_get_solar_forecast
platforms[domain] = platform.async_get_solar_forecast
await async_process_integration_platforms(
hass, DOMAIN, _process_energy_platform, wait_for_platforms=True