Convert Integration platforms processors where nothing is awaited to callbacks (#110825)

Convert Integration platforms processors where nothing is awaited callbacks
This commit is contained in:
J. Nick Koston 2024-02-17 19:49:47 -06:00 committed by GitHub
parent 165d79b553
commit 0d4c82b54d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 29 additions and 20 deletions

View file

@ -15,7 +15,7 @@ from typing import Any, Protocol, cast
from securetar import SecureTarFile, atomic_contents_add
from homeassistant.const import __version__ as HAVERSION
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import integration_platform
from homeassistant.helpers.json import json_bytes
@ -65,7 +65,8 @@ class BackupManager:
self.loaded_backups = False
self.loaded_platforms = False
async def _add_platform(
@callback
def _add_platform(
self,
hass: HomeAssistant,
integration_domain: str,

View file

@ -8,7 +8,7 @@ from pychromecast import Chromecast
from homeassistant.components.media_player import BrowseMedia, MediaType
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, device_registry as dr
from homeassistant.helpers.integration_platform import (
@ -66,7 +66,8 @@ class CastProtocol(Protocol):
"""
async def _register_cast_platform(
@callback
def _register_cast_platform(
hass: HomeAssistant, integration_domain: str, platform: CastProtocol
):
"""Register a cast platform."""

View file

@ -85,7 +85,8 @@ class DiagnosticsProtocol(Protocol):
"""Return diagnostics for a device."""
async def _register_diagnostics_platform(
@callback
def _register_diagnostics_platform(
hass: HomeAssistant, integration_domain: str, platform: DiagnosticsProtocol
) -> None:
"""Register a diagnostics platform."""

View file

@ -61,7 +61,8 @@ async def async_get_energy_platforms(
"""Get energy platforms."""
platforms: dict[str, GetSolarForecastType] = {}
async def _process_energy_platform(
@callback
def _process_energy_platform(
hass: HomeAssistant, domain: str, platform: ModuleType
) -> None:
"""Process energy platforms."""

View file

@ -383,7 +383,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
async def _process_group_platform(
@callback
def _process_group_platform(
hass: HomeAssistant, domain: str, platform: GroupProtocol
) -> None:
"""Process a group platform."""

View file

@ -1,7 +1,7 @@
"""The Hardware integration."""
from __future__ import annotations
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.integration_platform import (
async_process_integration_platforms,
@ -18,7 +18,8 @@ async def async_process_hardware_platforms(hass: HomeAssistant) -> None:
await async_process_integration_platforms(hass, DOMAIN, _register_hardware_platform)
async def _register_hardware_platform(
@callback
def _register_hardware_platform(
hass: HomeAssistant, integration_domain: str, platform: HardwareProtocol
) -> None:
"""Register a hardware platform."""

View file

@ -145,9 +145,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
async def _process_logbook_platform(
hass: HomeAssistant, domain: str, platform: Any
) -> None:
@callback
def _process_logbook_platform(hass: HomeAssistant, domain: str, platform: Any) -> None:
"""Process a logbook platform."""
logbook_config: LogbookConfig = hass.data[DOMAIN]
external_events = logbook_config.external_events

View file

@ -12,7 +12,7 @@ from homeassistant.const import (
EVENT_RECORDER_HOURLY_STATISTICS_GENERATED, # noqa: F401
EVENT_STATE_CHANGED,
)
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import (
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
@ -178,7 +178,8 @@ async def _async_setup_integration_platform(
) -> None:
"""Set up a recorder integration platform."""
async def _process_recorder_platform(
@callback
def _process_recorder_platform(
hass: HomeAssistant, domain: str, platform: Any
) -> None:
"""Process a recorder platform."""

View file

@ -105,7 +105,8 @@ async def async_process_repairs_platforms(hass: HomeAssistant) -> None:
await async_process_integration_platforms(hass, DOMAIN, _register_repairs_platform)
async def _register_repairs_platform(
@callback
def _register_repairs_platform(
hass: HomeAssistant, integration_domain: str, platform: RepairsProtocol
) -> None:
"""Register a repairs platform."""

View file

@ -70,7 +70,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
async def _register_system_health_platform(
@callback
def _register_system_health_platform(
hass: HomeAssistant, integration_domain: str, platform: SystemHealthProtocol
) -> None:
"""Register a system health platform."""

View file

@ -82,7 +82,8 @@ async def _initialize(hass: HomeAssistant) -> None:
functions = hass.data[DATA_FUNCTIONS] = {}
async def process_platform(
@callback
def process_platform(
hass: HomeAssistant, component_name: str, platform: Any
) -> None:
"""Process a significant change platform."""

View file

@ -2654,7 +2654,7 @@ async def test_get_events_with_device_ids(
async_describe_event("test", "mock_event", async_describe_test_event)
await logbook._process_logbook_platform(hass, "test", MockLogbookPlatform)
logbook._process_logbook_platform(hass, "test", MockLogbookPlatform)
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
hass.bus.async_fire("mock_event", {"device_id": device.id})

View file

@ -82,7 +82,7 @@ async def _async_mock_logbook_platform_with_broken_describe(
async_describe_event("test", "mock_event", async_describe_test_event)
await logbook._process_logbook_platform(hass, "test", MockLogbookPlatform)
logbook._process_logbook_platform(hass, "test", MockLogbookPlatform)
async def _async_mock_logbook_platform(hass: HomeAssistant) -> None:
@ -108,7 +108,7 @@ async def _async_mock_logbook_platform(hass: HomeAssistant) -> None:
async_describe_event("test", "mock_event", async_describe_test_event)
await logbook._process_logbook_platform(hass, "test", MockLogbookPlatform)
logbook._process_logbook_platform(hass, "test", MockLogbookPlatform)
async def _async_mock_entity_with_broken_logbook_platform(