From be68feffddb99b684e876f7f59f770c1e33d7226 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 7 Jan 2024 10:42:38 +0100 Subject: [PATCH] Enable strict typing for enphase_envoy (#107436) --- .strict-typing | 1 + .../components/enphase_envoy/config_flow.py | 6 +++--- homeassistant/components/enphase_envoy/switch.py | 12 ++++++------ mypy.ini | 10 ++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.strict-typing b/.strict-typing index 8134581fb5d..22a619dde69 100644 --- a/.strict-typing +++ b/.strict-typing @@ -155,6 +155,7 @@ homeassistant.components.emulated_hue.* homeassistant.components.energy.* homeassistant.components.energyzero.* homeassistant.components.enigma2.* +homeassistant.components.enphase_envoy.* homeassistant.components.esphome.* homeassistant.components.event.* homeassistant.components.evil_genius_labs.* diff --git a/homeassistant/components/enphase_envoy/config_flow.py b/homeassistant/components/enphase_envoy/config_flow.py index 999542ee2a5..939359f7fbf 100644 --- a/homeassistant/components/enphase_envoy/config_flow.py +++ b/homeassistant/components/enphase_envoy/config_flow.py @@ -42,12 +42,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - def __init__(self): + def __init__(self) -> None: """Initialize an envoy flow.""" - self.ip_address = None + self.ip_address: str | None = None self.username = None self.protovers: str | None = None - self._reauth_entry = None + self._reauth_entry: config_entries.ConfigEntry | None = None @callback def _async_generate_schema(self) -> vol.Schema: diff --git a/homeassistant/components/enphase_envoy/switch.py b/homeassistant/components/enphase_envoy/switch.py index 76c73914db6..921c5601dac 100644 --- a/homeassistant/components/enphase_envoy/switch.py +++ b/homeassistant/components/enphase_envoy/switch.py @@ -169,12 +169,12 @@ class EnvoyEnpowerSwitchEntity(EnvoyBaseEntity, SwitchEntity): assert enpower is not None return self.entity_description.value_fn(enpower) - async def async_turn_on(self): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the Enpower switch.""" await self.entity_description.turn_on_fn(self.envoy) await self.coordinator.async_request_refresh() - async def async_turn_off(self): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the Enpower switch.""" await self.entity_description.turn_off_fn(self.envoy) await self.coordinator.async_request_refresh() @@ -217,12 +217,12 @@ class EnvoyDryContactSwitchEntity(EnvoyBaseEntity, SwitchEntity): assert relay is not None return self.entity_description.value_fn(relay) - async def async_turn_on(self): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on (close) the dry contact.""" if await self.entity_description.turn_on_fn(self.envoy, self.relay_id): self.async_write_ha_state() - async def async_turn_off(self): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off (open) the dry contact.""" if await self.entity_description.turn_off_fn(self.envoy, self.relay_id): self.async_write_ha_state() @@ -261,12 +261,12 @@ class EnvoyStorageSettingsSwitchEntity(EnvoyBaseEntity, SwitchEntity): assert self.data.tariff.storage_settings is not None return self.entity_description.value_fn(self.data.tariff.storage_settings) - async def async_turn_on(self): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the storage settings switch.""" await self.entity_description.turn_on_fn(self.envoy) await self.coordinator.async_request_refresh() - async def async_turn_off(self): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the storage switch.""" await self.entity_description.turn_off_fn(self.envoy) await self.coordinator.async_request_refresh() diff --git a/mypy.ini b/mypy.ini index c670e7b1c5e..dbcaf3a840d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1311,6 +1311,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.enphase_envoy.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.esphome.*] check_untyped_defs = true disallow_incomplete_defs = true