From 421167c548bad838b40e33ca78f473f6e675298c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 23 May 2022 12:18:17 +0200 Subject: [PATCH] Drop GetAutomationsResult and GetAutomationCapabilitiesResult aliases (#72328) --- .../components/arcam_fmj/device_trigger.py | 7 ++----- .../components/device_automation/__init__.py | 3 --- .../components/device_automation/action.py | 11 +++-------- .../components/device_automation/condition.py | 13 ++++--------- .../components/device_automation/trigger.py | 8 +++----- .../components/homekit_controller/device_trigger.py | 7 ++----- .../components/lutron_caseta/device_trigger.py | 7 ++----- homeassistant/components/nest/device_trigger.py | 7 ++----- homeassistant/components/netatmo/device_trigger.py | 7 ++----- homeassistant/components/shelly/device_trigger.py | 9 +++------ homeassistant/components/webostv/device_trigger.py | 7 ++----- 11 files changed, 25 insertions(+), 61 deletions(-) diff --git a/homeassistant/components/arcam_fmj/device_trigger.py b/homeassistant/components/arcam_fmj/device_trigger.py index 46c51789dfb..593250e4983 100644 --- a/homeassistant/components/arcam_fmj/device_trigger.py +++ b/homeassistant/components/arcam_fmj/device_trigger.py @@ -7,10 +7,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.const import ( ATTR_ENTITY_ID, CONF_DEVICE_ID, @@ -36,7 +33,7 @@ TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend( async def async_get_triggers( hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for Arcam FMJ Receiver control devices.""" registry = entity_registry.async_get(hass) triggers = [] diff --git a/homeassistant/components/device_automation/__init__.py b/homeassistant/components/device_automation/__init__.py index e24ae15f9ff..61fd93354fe 100644 --- a/homeassistant/components/device_automation/__init__.py +++ b/homeassistant/components/device_automation/__init__.py @@ -44,9 +44,6 @@ if TYPE_CHECKING: ] # mypy: allow-untyped-calls, allow-untyped-defs -GetAutomationsResult = list[dict[str, Any]] -GetAutomationCapabilitiesResult = dict[str, vol.Schema] - DOMAIN = "device_automation" DEVICE_TRIGGER_BASE_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( diff --git a/homeassistant/components/device_automation/action.py b/homeassistant/components/device_automation/action.py index b15ca12a927..5737fbc5bf3 100644 --- a/homeassistant/components/device_automation/action.py +++ b/homeassistant/components/device_automation/action.py @@ -10,12 +10,7 @@ from homeassistant.const import CONF_DOMAIN from homeassistant.core import Context, HomeAssistant from homeassistant.helpers.typing import ConfigType -from . import ( - DeviceAutomationType, - GetAutomationCapabilitiesResult, - GetAutomationsResult, - async_get_device_automation_platform, -) +from . import DeviceAutomationType, async_get_device_automation_platform from .exceptions import InvalidDeviceAutomationConfig @@ -43,12 +38,12 @@ class DeviceAutomationActionProtocol(Protocol): def async_get_action_capabilities( self, hass: HomeAssistant, config: ConfigType - ) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]: + ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]: """List action capabilities.""" def async_get_actions( self, hass: HomeAssistant, device_id: str - ) -> GetAutomationsResult | Awaitable[GetAutomationsResult]: + ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]: """List actions.""" diff --git a/homeassistant/components/device_automation/condition.py b/homeassistant/components/device_automation/condition.py index 7ff3216c702..1f1f8e94832 100644 --- a/homeassistant/components/device_automation/condition.py +++ b/homeassistant/components/device_automation/condition.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections.abc import Awaitable -from typing import TYPE_CHECKING, Protocol, cast +from typing import TYPE_CHECKING, Any, Protocol, cast import voluptuous as vol @@ -11,12 +11,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from homeassistant.helpers.typing import ConfigType -from . import ( - DeviceAutomationType, - GetAutomationCapabilitiesResult, - GetAutomationsResult, - async_get_device_automation_platform, -) +from . import DeviceAutomationType, async_get_device_automation_platform from .exceptions import InvalidDeviceAutomationConfig if TYPE_CHECKING: @@ -43,12 +38,12 @@ class DeviceAutomationConditionProtocol(Protocol): def async_get_condition_capabilities( self, hass: HomeAssistant, config: ConfigType - ) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]: + ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]: """List condition capabilities.""" def async_get_conditions( self, hass: HomeAssistant, device_id: str - ) -> GetAutomationsResult | Awaitable[GetAutomationsResult]: + ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]: """List conditions.""" diff --git a/homeassistant/components/device_automation/trigger.py b/homeassistant/components/device_automation/trigger.py index e4a740d6599..c5f42b3e813 100644 --- a/homeassistant/components/device_automation/trigger.py +++ b/homeassistant/components/device_automation/trigger.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections.abc import Awaitable -from typing import Protocol, cast +from typing import Any, Protocol, cast import voluptuous as vol @@ -17,8 +17,6 @@ from homeassistant.helpers.typing import ConfigType from . import ( DEVICE_TRIGGER_BASE_SCHEMA, DeviceAutomationType, - GetAutomationCapabilitiesResult, - GetAutomationsResult, async_get_device_automation_platform, ) from .exceptions import InvalidDeviceAutomationConfig @@ -50,12 +48,12 @@ class DeviceAutomationTriggerProtocol(Protocol): def async_get_trigger_capabilities( self, hass: HomeAssistant, config: ConfigType - ) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]: + ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]: """List trigger capabilities.""" def async_get_triggers( self, hass: HomeAssistant, device_id: str - ) -> GetAutomationsResult | Awaitable[GetAutomationsResult]: + ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]: """List triggers.""" diff --git a/homeassistant/components/homekit_controller/device_trigger.py b/homeassistant/components/homekit_controller/device_trigger.py index 5c46aee6ca2..dcac7238c8e 100644 --- a/homeassistant/components/homekit_controller/device_trigger.py +++ b/homeassistant/components/homekit_controller/device_trigger.py @@ -14,10 +14,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback from homeassistant.helpers.typing import ConfigType @@ -244,7 +241,7 @@ def async_fire_triggers(conn: HKDevice, events: dict[tuple[int, int], Any]): async def async_get_triggers( hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for homekit devices.""" if device_id not in hass.data.get(TRIGGERS, {}): diff --git a/homeassistant/components/lutron_caseta/device_trigger.py b/homeassistant/components/lutron_caseta/device_trigger.py index b6f01a5e49e..68394667764 100644 --- a/homeassistant/components/lutron_caseta/device_trigger.py +++ b/homeassistant/components/lutron_caseta/device_trigger.py @@ -7,10 +7,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) @@ -350,7 +347,7 @@ async def async_validate_trigger_config( async def async_get_triggers( hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for lutron caseta devices.""" triggers = [] diff --git a/homeassistant/components/nest/device_trigger.py b/homeassistant/components/nest/device_trigger.py index e2f4288d122..05769a407f2 100644 --- a/homeassistant/components/nest/device_trigger.py +++ b/homeassistant/components/nest/device_trigger.py @@ -8,10 +8,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) @@ -66,7 +63,7 @@ def async_get_device_trigger_types( async def async_get_triggers( hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for a Nest device.""" nest_device_id = async_get_nest_device_id(hass, device_id) if not nest_device_id: diff --git a/homeassistant/components/netatmo/device_trigger.py b/homeassistant/components/netatmo/device_trigger.py index ce03aa91905..25f76307b5f 100644 --- a/homeassistant/components/netatmo/device_trigger.py +++ b/homeassistant/components/netatmo/device_trigger.py @@ -7,10 +7,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) @@ -101,7 +98,7 @@ async def async_validate_trigger_config( async def async_get_triggers( hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for Netatmo devices.""" registry = entity_registry.async_get(hass) device_registry = dr.async_get(hass) diff --git a/homeassistant/components/shelly/device_trigger.py b/homeassistant/components/shelly/device_trigger.py index 1231f670d49..0f9fc55ed71 100644 --- a/homeassistant/components/shelly/device_trigger.py +++ b/homeassistant/components/shelly/device_trigger.py @@ -9,10 +9,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) @@ -111,9 +108,9 @@ async def async_validate_trigger_config( async def async_get_triggers( hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for Shelly devices.""" - triggers: GetAutomationsResult = [] + triggers: list[dict[str, str]] = [] if rpc_wrapper := get_rpc_device_wrapper(hass, device_id): input_triggers = get_rpc_input_triggers(rpc_wrapper.device) diff --git a/homeassistant/components/webostv/device_trigger.py b/homeassistant/components/webostv/device_trigger.py index 9836f561b9d..9ce49bbe79e 100644 --- a/homeassistant/components/webostv/device_trigger.py +++ b/homeassistant/components/webostv/device_trigger.py @@ -7,10 +7,7 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - GetAutomationsResult, -) +from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) @@ -61,7 +58,7 @@ async def async_validate_trigger_config( async def async_get_triggers( _hass: HomeAssistant, device_id: str -) -> GetAutomationsResult: +) -> list[dict[str, str]]: """List device triggers for device.""" triggers = [] base_trigger = {