mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Rename callback type
This commit is contained in:
@@ -23,8 +23,8 @@ from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.automation import move_top_level_schema_fields_to_options
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.trigger import (
|
||||
RunTriggerActionCallback,
|
||||
Trigger,
|
||||
TriggerActionRunnerCallback,
|
||||
TriggerConfig,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
@@ -131,7 +131,7 @@ class EventTrigger(Trigger):
|
||||
_event_name: str
|
||||
_event_data_filter: dict
|
||||
_unsubs: list[Callable]
|
||||
_action_runner: RunTriggerActionCallback
|
||||
_action_runner: TriggerActionRunnerCallback
|
||||
|
||||
@classmethod
|
||||
async def async_validate_complete_config(
|
||||
@@ -175,7 +175,7 @@ class EventTrigger(Trigger):
|
||||
self._options = config.options
|
||||
|
||||
async def async_attach_runner(
|
||||
self, run_action: RunTriggerActionCallback
|
||||
self, run_action: TriggerActionRunnerCallback
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Attach a trigger."""
|
||||
dev_reg = dr.async_get(self._hass)
|
||||
|
||||
@@ -17,8 +17,8 @@ from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.automation import move_top_level_schema_fields_to_options
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.trigger import (
|
||||
RunTriggerActionCallback,
|
||||
Trigger,
|
||||
TriggerActionRunnerCallback,
|
||||
TriggerConfig,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
@@ -93,7 +93,7 @@ async def async_validate_trigger_config(
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
hass: HomeAssistant, options: ConfigType, run_action: RunTriggerActionCallback
|
||||
hass: HomeAssistant, options: ConfigType, run_action: TriggerActionRunnerCallback
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Listen for state changes based on configuration."""
|
||||
dev_reg = dr.async_get(hass)
|
||||
@@ -232,7 +232,7 @@ class ValueUpdatedTrigger(Trigger):
|
||||
self._options = config.options
|
||||
|
||||
async def async_attach_runner(
|
||||
self, run_action: RunTriggerActionCallback
|
||||
self, run_action: TriggerActionRunnerCallback
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Attach a trigger."""
|
||||
return await async_attach_trigger(self._hass, self._options, run_action)
|
||||
|
||||
@@ -237,7 +237,7 @@ class Trigger(abc.ABC):
|
||||
|
||||
@abc.abstractmethod
|
||||
async def async_attach_runner(
|
||||
self, run_action: RunTriggerActionCallback
|
||||
self, run_action: TriggerActionRunnerCallback
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Attach the trigger to an action runner."""
|
||||
|
||||
@@ -277,7 +277,7 @@ class TriggerConfig:
|
||||
options: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class RunTriggerActionCallback(Protocol):
|
||||
class TriggerActionRunnerCallback(Protocol):
|
||||
"""Protocol type for the trigger action runner helper callback."""
|
||||
|
||||
@callback
|
||||
|
||||
@@ -23,8 +23,8 @@ from homeassistant.helpers.automation import move_top_level_schema_fields_to_opt
|
||||
from homeassistant.helpers.trigger import (
|
||||
DATA_PLUGGABLE_ACTIONS,
|
||||
PluggableAction,
|
||||
RunTriggerActionCallback,
|
||||
Trigger,
|
||||
TriggerActionRunnerCallback,
|
||||
_async_get_trigger_platform,
|
||||
async_initialize_triggers,
|
||||
async_validate_trigger_config,
|
||||
@@ -464,7 +464,7 @@ async def test_platform_multiple_triggers(hass: HomeAssistant) -> None:
|
||||
"""Mock trigger 1."""
|
||||
|
||||
async def async_attach_runner(
|
||||
self, run_action: RunTriggerActionCallback
|
||||
self, run_action: TriggerActionRunnerCallback
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Attach a trigger."""
|
||||
run_action("trigger 1 desc", {"extra": "test_trigger_1"})
|
||||
@@ -473,7 +473,7 @@ async def test_platform_multiple_triggers(hass: HomeAssistant) -> None:
|
||||
"""Mock trigger 2."""
|
||||
|
||||
async def async_attach_runner(
|
||||
self, run_action: RunTriggerActionCallback
|
||||
self, run_action: TriggerActionRunnerCallback
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Attach a trigger."""
|
||||
run_action("trigger 2 desc", {"extra": "test_trigger_2"})
|
||||
|
||||
Reference in New Issue
Block a user