mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
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:
parent
165d79b553
commit
0d4c82b54d
@ -15,7 +15,7 @@ from typing import Any, Protocol, cast
|
|||||||
from securetar import SecureTarFile, atomic_contents_add
|
from securetar import SecureTarFile, atomic_contents_add
|
||||||
|
|
||||||
from homeassistant.const import __version__ as HAVERSION
|
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.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import integration_platform
|
from homeassistant.helpers import integration_platform
|
||||||
from homeassistant.helpers.json import json_bytes
|
from homeassistant.helpers.json import json_bytes
|
||||||
@ -65,7 +65,8 @@ class BackupManager:
|
|||||||
self.loaded_backups = False
|
self.loaded_backups = False
|
||||||
self.loaded_platforms = False
|
self.loaded_platforms = False
|
||||||
|
|
||||||
async def _add_platform(
|
@callback
|
||||||
|
def _add_platform(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
integration_domain: str,
|
integration_domain: str,
|
||||||
|
@ -8,7 +8,7 @@ from pychromecast import Chromecast
|
|||||||
from homeassistant.components.media_player import BrowseMedia, MediaType
|
from homeassistant.components.media_player import BrowseMedia, MediaType
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
from homeassistant.helpers.integration_platform import (
|
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
|
hass: HomeAssistant, integration_domain: str, platform: CastProtocol
|
||||||
):
|
):
|
||||||
"""Register a cast platform."""
|
"""Register a cast platform."""
|
||||||
|
@ -85,7 +85,8 @@ class DiagnosticsProtocol(Protocol):
|
|||||||
"""Return diagnostics for a device."""
|
"""Return diagnostics for a device."""
|
||||||
|
|
||||||
|
|
||||||
async def _register_diagnostics_platform(
|
@callback
|
||||||
|
def _register_diagnostics_platform(
|
||||||
hass: HomeAssistant, integration_domain: str, platform: DiagnosticsProtocol
|
hass: HomeAssistant, integration_domain: str, platform: DiagnosticsProtocol
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register a diagnostics platform."""
|
"""Register a diagnostics platform."""
|
||||||
|
@ -61,7 +61,8 @@ async def async_get_energy_platforms(
|
|||||||
"""Get energy platforms."""
|
"""Get energy platforms."""
|
||||||
platforms: dict[str, GetSolarForecastType] = {}
|
platforms: dict[str, GetSolarForecastType] = {}
|
||||||
|
|
||||||
async def _process_energy_platform(
|
@callback
|
||||||
|
def _process_energy_platform(
|
||||||
hass: HomeAssistant, domain: str, platform: ModuleType
|
hass: HomeAssistant, domain: str, platform: ModuleType
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Process energy platforms."""
|
"""Process energy platforms."""
|
||||||
|
@ -383,7 +383,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def _process_group_platform(
|
@callback
|
||||||
|
def _process_group_platform(
|
||||||
hass: HomeAssistant, domain: str, platform: GroupProtocol
|
hass: HomeAssistant, domain: str, platform: GroupProtocol
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Process a group platform."""
|
"""Process a group platform."""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""The Hardware integration."""
|
"""The Hardware integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.integration_platform import (
|
from homeassistant.helpers.integration_platform import (
|
||||||
async_process_integration_platforms,
|
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)
|
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
|
hass: HomeAssistant, integration_domain: str, platform: HardwareProtocol
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register a hardware platform."""
|
"""Register a hardware platform."""
|
||||||
|
@ -145,9 +145,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def _process_logbook_platform(
|
@callback
|
||||||
hass: HomeAssistant, domain: str, platform: Any
|
def _process_logbook_platform(hass: HomeAssistant, domain: str, platform: Any) -> None:
|
||||||
) -> None:
|
|
||||||
"""Process a logbook platform."""
|
"""Process a logbook platform."""
|
||||||
logbook_config: LogbookConfig = hass.data[DOMAIN]
|
logbook_config: LogbookConfig = hass.data[DOMAIN]
|
||||||
external_events = logbook_config.external_events
|
external_events = logbook_config.external_events
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||||||
EVENT_RECORDER_HOURLY_STATISTICS_GENERATED, # noqa: F401
|
EVENT_RECORDER_HOURLY_STATISTICS_GENERATED, # noqa: F401
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entityfilter import (
|
from homeassistant.helpers.entityfilter import (
|
||||||
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
|
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
|
||||||
@ -178,7 +178,8 @@ async def _async_setup_integration_platform(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a recorder integration platform."""
|
"""Set up a recorder integration platform."""
|
||||||
|
|
||||||
async def _process_recorder_platform(
|
@callback
|
||||||
|
def _process_recorder_platform(
|
||||||
hass: HomeAssistant, domain: str, platform: Any
|
hass: HomeAssistant, domain: str, platform: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Process a recorder platform."""
|
"""Process a recorder platform."""
|
||||||
|
@ -105,7 +105,8 @@ async def async_process_repairs_platforms(hass: HomeAssistant) -> None:
|
|||||||
await async_process_integration_platforms(hass, DOMAIN, _register_repairs_platform)
|
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
|
hass: HomeAssistant, integration_domain: str, platform: RepairsProtocol
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register a repairs platform."""
|
"""Register a repairs platform."""
|
||||||
|
@ -70,7 +70,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def _register_system_health_platform(
|
@callback
|
||||||
|
def _register_system_health_platform(
|
||||||
hass: HomeAssistant, integration_domain: str, platform: SystemHealthProtocol
|
hass: HomeAssistant, integration_domain: str, platform: SystemHealthProtocol
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register a system health platform."""
|
"""Register a system health platform."""
|
||||||
|
@ -82,7 +82,8 @@ async def _initialize(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
functions = hass.data[DATA_FUNCTIONS] = {}
|
functions = hass.data[DATA_FUNCTIONS] = {}
|
||||||
|
|
||||||
async def process_platform(
|
@callback
|
||||||
|
def process_platform(
|
||||||
hass: HomeAssistant, component_name: str, platform: Any
|
hass: HomeAssistant, component_name: str, platform: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Process a significant change platform."""
|
"""Process a significant change platform."""
|
||||||
|
@ -2654,7 +2654,7 @@ async def test_get_events_with_device_ids(
|
|||||||
|
|
||||||
async_describe_event("test", "mock_event", async_describe_test_event)
|
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(EVENT_HOMEASSISTANT_START)
|
||||||
hass.bus.async_fire("mock_event", {"device_id": device.id})
|
hass.bus.async_fire("mock_event", {"device_id": device.id})
|
||||||
|
@ -82,7 +82,7 @@ async def _async_mock_logbook_platform_with_broken_describe(
|
|||||||
|
|
||||||
async_describe_event("test", "mock_event", async_describe_test_event)
|
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:
|
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)
|
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(
|
async def _async_mock_entity_with_broken_logbook_platform(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user