From 21bdcd6b63a90a543725f50c2ce3b9cc95c0a844 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 15 Jun 2023 20:16:17 +0200 Subject: [PATCH] Remove str as a valid HVACMode & HVACAction type (#94644) * Remove str as a valid HAVCMode type * Adjust pylint plugin * Also remove str from hvac_action property method --- homeassistant/components/climate/__init__.py | 12 ++++++------ pylint/plugins/hass_enforce_type_hints.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index ed0f8f2a4aa..c5bc22ebc0c 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -214,9 +214,9 @@ class ClimateEntity(Entity): _attr_current_temperature: float | None = None _attr_fan_mode: str | None _attr_fan_modes: list[str] | None - _attr_hvac_action: HVACAction | str | None = None - _attr_hvac_mode: HVACMode | str | None - _attr_hvac_modes: list[HVACMode] | list[str] + _attr_hvac_action: HVACAction | None = None + _attr_hvac_mode: HVACMode | None + _attr_hvac_modes: list[HVACMode] _attr_is_aux_heat: bool | None _attr_max_humidity: int = DEFAULT_MAX_HUMIDITY _attr_max_temp: float @@ -361,17 +361,17 @@ class ClimateEntity(Entity): return self._attr_target_humidity @property - def hvac_mode(self) -> HVACMode | str | None: + def hvac_mode(self) -> HVACMode | None: """Return hvac operation ie. heat, cool mode.""" return self._attr_hvac_mode @property - def hvac_modes(self) -> list[HVACMode] | list[str]: + def hvac_modes(self) -> list[HVACMode]: """Return the list of available hvac operation modes.""" return self._attr_hvac_modes @property - def hvac_action(self) -> HVACAction | str | None: + def hvac_action(self) -> HVACAction | None: """Return the current running hvac operation if supported.""" return self._attr_hvac_action diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 0320ff2d4f4..85b1b1370a1 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1023,15 +1023,15 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ), TypeHintMatch( function_name="hvac_mode", - return_type=["HVACMode", "str", None], + return_type=["HVACMode", None], ), TypeHintMatch( function_name="hvac_modes", - return_type=["list[HVACMode]", "list[str]"], + return_type="list[HVACMode]", ), TypeHintMatch( function_name="hvac_action", - return_type=["HVACAction", "str", None], + return_type=["HVACAction", None], ), TypeHintMatch( function_name="current_temperature",