From de6e7ea016743e3dccbfe9bac0519650108ca387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 21 Aug 2021 10:20:09 +0300 Subject: [PATCH] Replace *args and **kwargs type hint collections with value types (#54955) --- homeassistant/components/guardian/switch.py | 4 ++-- homeassistant/components/netatmo/climate.py | 6 +++--- homeassistant/components/netatmo/light.py | 6 +++--- homeassistant/components/rainmachine/switch.py | 8 ++++---- homeassistant/components/simplisafe/lock.py | 4 ++-- homeassistant/components/switcher_kis/switch.py | 4 ++-- homeassistant/components/zwave_js/lock.py | 8 +++----- homeassistant/helpers/deprecation.py | 4 ++-- homeassistant/helpers/template.py | 2 +- 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/guardian/switch.py b/homeassistant/components/guardian/switch.py index f3621a72952..7343a1f5c27 100644 --- a/homeassistant/components/guardian/switch.py +++ b/homeassistant/components/guardian/switch.py @@ -201,7 +201,7 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity): except GuardianError as err: LOGGER.error("Error while upgrading firmware: %s", err) - async def async_turn_off(self, **kwargs: dict[str, Any]) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the valve off (closed).""" try: async with self._client: @@ -213,7 +213,7 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity): self._attr_is_on = False self.async_write_ha_state() - async def async_turn_on(self, **kwargs: dict[str, Any]) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the valve on (open).""" try: async with self._client: diff --git a/homeassistant/components/netatmo/climate.py b/homeassistant/components/netatmo/climate.py index 6622c891df1..e71b6939982 100644 --- a/homeassistant/components/netatmo/climate.py +++ b/homeassistant/components/netatmo/climate.py @@ -2,7 +2,7 @@ from __future__ import annotations import logging -from typing import cast +from typing import Any, cast import pyatmo import voluptuous as vol @@ -439,7 +439,7 @@ class NetatmoThermostat(NetatmoBase, ClimateEntity): """Return a list of available preset modes.""" return SUPPORT_PRESET - async def async_set_temperature(self, **kwargs: dict) -> None: + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature for 2 hours.""" temp = kwargs.get(ATTR_TEMPERATURE) if temp is None: @@ -589,7 +589,7 @@ class NetatmoThermostat(NetatmoBase, ClimateEntity): return {} - async def _async_service_set_schedule(self, **kwargs: dict) -> None: + async def _async_service_set_schedule(self, **kwargs: Any) -> None: schedule_name = kwargs.get(ATTR_SCHEDULE_NAME) schedule_id = None for sid, name in self.hass.data[DOMAIN][DATA_SCHEDULES][self._home_id].items(): diff --git a/homeassistant/components/netatmo/light.py b/homeassistant/components/netatmo/light.py index 6fe5e84e65a..34c0d023edc 100644 --- a/homeassistant/components/netatmo/light.py +++ b/homeassistant/components/netatmo/light.py @@ -2,7 +2,7 @@ from __future__ import annotations import logging -from typing import cast +from typing import Any, cast import pyatmo @@ -141,7 +141,7 @@ class NetatmoLight(NetatmoBase, LightEntity): """Return true if light is on.""" return self._is_on - async def async_turn_on(self, **kwargs: dict) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn camera floodlight on.""" _LOGGER.debug("Turn camera '%s' on", self.name) await self._data.async_set_state( @@ -150,7 +150,7 @@ class NetatmoLight(NetatmoBase, LightEntity): floodlight="on", ) - async def async_turn_off(self, **kwargs: dict) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn camera floodlight into auto mode.""" _LOGGER.debug("Turn camera '%s' to auto mode", self.name) await self._data.async_set_state( diff --git a/homeassistant/components/rainmachine/switch.py b/homeassistant/components/rainmachine/switch.py index 9554b22d783..361a737218d 100644 --- a/homeassistant/components/rainmachine/switch.py +++ b/homeassistant/components/rainmachine/switch.py @@ -313,13 +313,13 @@ class RainMachineProgram(RainMachineSwitch): """Return a list of active zones associated with this program.""" return [z for z in self._data["wateringTimes"] if z["active"]] - async def async_turn_off(self, **kwargs: dict[str, Any]) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the program off.""" await self._async_run_switch_coroutine( self._controller.programs.stop(self._uid) ) - async def async_turn_on(self, **kwargs: dict[str, Any]) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the program on.""" await self._async_run_switch_coroutine( self._controller.programs.start(self._uid) @@ -353,11 +353,11 @@ class RainMachineProgram(RainMachineSwitch): class RainMachineZone(RainMachineSwitch): """A RainMachine zone.""" - async def async_turn_off(self, **kwargs: dict[str, Any]) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the zone off.""" await self._async_run_switch_coroutine(self._controller.zones.stop(self._uid)) - async def async_turn_on(self, **kwargs: dict[str, Any]) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the zone on.""" await self._async_run_switch_coroutine( self._controller.zones.start( diff --git a/homeassistant/components/simplisafe/lock.py b/homeassistant/components/simplisafe/lock.py index 3068e6209ae..e5f6faba10f 100644 --- a/homeassistant/components/simplisafe/lock.py +++ b/homeassistant/components/simplisafe/lock.py @@ -46,7 +46,7 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity): self._lock = lock - async def async_lock(self, **kwargs: dict[str, Any]) -> None: + async def async_lock(self, **kwargs: Any) -> None: """Lock the lock.""" try: await self._lock.lock() @@ -57,7 +57,7 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity): self._attr_is_locked = True self.async_write_ha_state() - async def async_unlock(self, **kwargs: dict[str, Any]) -> None: + async def async_unlock(self, **kwargs: Any) -> None: """Unlock the lock.""" try: await self._lock.unlock() diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index c36fd0c208e..0eeeb881f45 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -137,13 +137,13 @@ class SwitcherBaseSwitchEntity(CoordinatorEntity, SwitchEntity): return bool(self.wrapper.data.device_state == DeviceState.ON) - async def async_turn_on(self, **kwargs: dict) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the entity on.""" await self._async_call_api("control_device", Command.ON) self.control_result = True self.async_write_ha_state() - async def async_turn_off(self, **kwargs: dict) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the entity off.""" await self._async_call_api("control_device", Command.OFF) self.control_result = False diff --git a/homeassistant/components/zwave_js/lock.py b/homeassistant/components/zwave_js/lock.py index ad4a736d63e..696310b5ad1 100644 --- a/homeassistant/components/zwave_js/lock.py +++ b/homeassistant/components/zwave_js/lock.py @@ -103,9 +103,7 @@ class ZWaveLock(ZWaveBaseEntity, LockEntity): ] ) == int(self.info.primary_value.value) - async def _set_lock_state( - self, target_state: str, **kwargs: dict[str, Any] - ) -> None: + async def _set_lock_state(self, target_state: str, **kwargs: Any) -> None: """Set the lock state.""" target_value: ZwaveValue = self.get_zwave_value( LOCK_CMD_CLASS_TO_PROPERTY_MAP[self.info.primary_value.command_class] @@ -116,11 +114,11 @@ class ZWaveLock(ZWaveBaseEntity, LockEntity): STATE_TO_ZWAVE_MAP[self.info.primary_value.command_class][target_state], ) - async def async_lock(self, **kwargs: dict[str, Any]) -> None: + async def async_lock(self, **kwargs: Any) -> None: """Lock the lock.""" await self._set_lock_state(STATE_LOCKED) - async def async_unlock(self, **kwargs: dict[str, Any]) -> None: + async def async_unlock(self, **kwargs: Any) -> None: """Unlock the lock.""" await self._set_lock_state(STATE_UNLOCKED) diff --git a/homeassistant/helpers/deprecation.py b/homeassistant/helpers/deprecation.py index adf3d8a5d88..e20748913ba 100644 --- a/homeassistant/helpers/deprecation.py +++ b/homeassistant/helpers/deprecation.py @@ -87,7 +87,7 @@ def deprecated_class(replacement: str) -> Any: """Decorate class as deprecated.""" @functools.wraps(cls) - def deprecated_cls(*args: tuple, **kwargs: dict[str, Any]) -> Any: + def deprecated_cls(*args: Any, **kwargs: Any) -> Any: """Wrap for the original class.""" _print_deprecation_warning(cls, replacement, "class") return cls(*args, **kwargs) @@ -104,7 +104,7 @@ def deprecated_function(replacement: str) -> Callable[..., Callable]: """Decorate function as deprecated.""" @functools.wraps(func) - def deprecated_func(*args: tuple, **kwargs: dict[str, Any]) -> Any: + def deprecated_func(*args: Any, **kwargs: Any) -> Any: """Wrap for the original function.""" _print_deprecation_warning(func, replacement, "function") return func(*args, **kwargs) diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 08b3956a490..cbeaa07aadc 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -151,7 +151,7 @@ def gen_result_wrapper(kls): class Wrapper(kls, ResultWrapper): """Wrapper of a kls that can store render_result.""" - def __init__(self, *args: tuple, render_result: str | None = None) -> None: + def __init__(self, *args: Any, render_result: str | None = None) -> None: super().__init__(*args) self.render_result = render_result