diff --git a/.strict-typing b/.strict-typing index 4a4151ce606..f49e576a774 100644 --- a/.strict-typing +++ b/.strict-typing @@ -88,6 +88,7 @@ homeassistant.components.camera.* homeassistant.components.canary.* homeassistant.components.clickatell.* homeassistant.components.clicksend.* +homeassistant.components.climate.* homeassistant.components.cloud.* homeassistant.components.configurator.* homeassistant.components.cover.* diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index 907ff84491b..dfc428a9bd0 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -242,8 +242,9 @@ class ClimateEntity(Entity): hvac_mode = self.hvac_mode if hvac_mode is None: return None + # Support hvac_mode as string for custom integration backwards compatibility if not isinstance(hvac_mode, HVACMode): - return HVACMode(hvac_mode).value + return HVACMode(hvac_mode).value # type: ignore[unreachable] return hvac_mode.value @property @@ -458,11 +459,11 @@ class ClimateEntity(Entity): """ return self._attr_swing_modes - def set_temperature(self, **kwargs) -> None: + def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" raise NotImplementedError() - async def async_set_temperature(self, **kwargs) -> None: + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" await self.hass.async_add_executor_job( ft.partial(self.set_temperature, **kwargs) diff --git a/homeassistant/components/climate/device_condition.py b/homeassistant/components/climate/device_condition.py index d9f1b240a9a..57b9654651b 100644 --- a/homeassistant/components/climate/device_condition.py +++ b/homeassistant/components/climate/device_condition.py @@ -92,9 +92,9 @@ def async_condition_from_config( return False if config[CONF_TYPE] == "is_hvac_mode": - return state.state == config[const.ATTR_HVAC_MODE] + return bool(state.state == config[const.ATTR_HVAC_MODE]) - return ( + return bool( state.attributes.get(const.ATTR_PRESET_MODE) == config[const.ATTR_PRESET_MODE] ) diff --git a/homeassistant/components/climate/reproduce_state.py b/homeassistant/components/climate/reproduce_state.py index 0bbc6fce7ec..2897a956fc6 100644 --- a/homeassistant/components/climate/reproduce_state.py +++ b/homeassistant/components/climate/reproduce_state.py @@ -38,7 +38,9 @@ async def _async_reproduce_states( ) -> None: """Reproduce component states.""" - async def call_service(service: str, keys: Iterable, data=None): + async def call_service( + service: str, keys: Iterable, data: dict[str, Any] | None = None + ) -> None: """Call service with set of attributes given.""" data = data or {} data["entity_id"] = state.entity_id diff --git a/mypy.ini b/mypy.ini index 14eb6bba841..6303f2b2706 100644 --- a/mypy.ini +++ b/mypy.ini @@ -641,6 +641,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.climate.*] +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.cloud.*] check_untyped_defs = true disallow_incomplete_defs = true