From d93d25a7d1abd295f5fdf92e6ff89e96bb79c185 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 2 Jan 2024 05:09:22 +0100 Subject: [PATCH] Enable strict typing for ambiclimate (#106819) --- .strict-typing | 1 + homeassistant/components/ambiclimate/climate.py | 5 +++-- homeassistant/components/ambiclimate/config_flow.py | 8 ++++---- mypy.ini | 10 ++++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.strict-typing b/.strict-typing index 9f23dce88fa..6bc8942486b 100644 --- a/.strict-typing +++ b/.strict-typing @@ -63,6 +63,7 @@ homeassistant.components.alexa.* homeassistant.components.alpha_vantage.* homeassistant.components.amazon_polly.* homeassistant.components.amberelectric.* +homeassistant.components.ambiclimate.* homeassistant.components.ambient_station.* homeassistant.components.amcrest.* homeassistant.components.ampio.* diff --git a/homeassistant/components/ambiclimate/climate.py b/homeassistant/components/ambiclimate/climate.py index 2762c3948a7..fc192d8658f 100644 --- a/homeassistant/components/ambiclimate/climate.py +++ b/homeassistant/components/ambiclimate/climate.py @@ -6,6 +6,7 @@ import logging from typing import Any import ambiclimate +from ambiclimate import AmbiclimateDevice import voluptuous as vol from homeassistant.components.climate import ( @@ -157,13 +158,13 @@ class AmbiclimateEntity(ClimateEntity): _attr_has_entity_name = True _attr_name = None - def __init__(self, heater, store): + def __init__(self, heater: AmbiclimateDevice, store: Store[dict[str, Any]]) -> None: """Initialize the thermostat.""" self._heater = heater self._store = store self._attr_unique_id = heater.device_id self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, self.unique_id)}, + identifiers={(DOMAIN, self.unique_id)}, # type: ignore[arg-type] manufacturer="Ambiclimate", name=heater.name, ) diff --git a/homeassistant/components/ambiclimate/config_flow.py b/homeassistant/components/ambiclimate/config_flow.py index 3d05ab2bb07..383a11055e4 100644 --- a/homeassistant/components/ambiclimate/config_flow.py +++ b/homeassistant/components/ambiclimate/config_flow.py @@ -114,7 +114,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): store = Store[dict[str, Any]](self.hass, STORAGE_VERSION, STORAGE_KEY) await store.async_save(token_info) - return token_info + return token_info # type: ignore[no-any-return] def _generate_view(self) -> None: self.hass.http.register_view(AmbiclimateAuthCallbackView()) @@ -132,12 +132,12 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): clientsession, ) - def _cb_url(self): + def _cb_url(self) -> str: return f"{get_url(self.hass, prefer_external=True)}{AUTH_CALLBACK_PATH}" - async def _get_authorize_url(self): + async def _get_authorize_url(self) -> str: oauth = self._generate_oauth() - return oauth.get_authorize_url() + return oauth.get_authorize_url() # type: ignore[no-any-return] class AmbiclimateAuthCallbackView(HomeAssistantView): diff --git a/mypy.ini b/mypy.ini index 01fcef8ac07..173b2dbd838 100644 --- a/mypy.ini +++ b/mypy.ini @@ -390,6 +390,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.ambiclimate.*] +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.ambient_station.*] check_untyped_defs = true disallow_incomplete_defs = true