From 2c171e30fa32a85d8a6a5cd3f3a40433b384c094 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 30 Jun 2022 23:49:23 +0200 Subject: [PATCH] Add ClimateEntity checks to pylint plugin (#74275) * Add ClimateEntity checks to pylint plugin * Update pylint/plugins/hass_enforce_type_hints.py --- pylint/plugins/hass_enforce_type_hints.py | 173 ++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 36c198c7218..8e846cf5db0 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -856,6 +856,179 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ], ), ], + "climate": [ + ClassTypeHintMatch( + base_class="Entity", + matches=_ENTITY_MATCH, + ), + ClassTypeHintMatch( + base_class="ClimateEntity", + matches=[ + TypeHintMatch( + function_name="precision", + return_type="float", + ), + TypeHintMatch( + function_name="temperature_unit", + return_type="str", + ), + TypeHintMatch( + function_name="current_humidity", + return_type=["int", None], + ), + TypeHintMatch( + function_name="target_humidity", + return_type=["int", None], + ), + TypeHintMatch( + function_name="hvac_mode", + return_type=["HVACMode", "str", None], + ), + TypeHintMatch( + function_name="hvac_modes", + return_type=["list[HVACMode]", "list[str]"], + ), + TypeHintMatch( + function_name="hvac_action", + return_type=["HVACAction", "str", None], + ), + TypeHintMatch( + function_name="current_temperature", + return_type=["float", None], + ), + TypeHintMatch( + function_name="target_temperature", + return_type=["float", None], + ), + TypeHintMatch( + function_name="target_temperature_step", + return_type=["float", None], + ), + TypeHintMatch( + function_name="target_temperature_high", + return_type=["float", None], + ), + TypeHintMatch( + function_name="target_temperature_low", + return_type=["float", None], + ), + TypeHintMatch( + function_name="preset_mode", + return_type=["str", None], + ), + TypeHintMatch( + function_name="preset_modes", + return_type=["list[str]", None], + ), + TypeHintMatch( + function_name="is_aux_heat", + return_type=["bool", None], + ), + TypeHintMatch( + function_name="fan_mode", + return_type=["str", None], + ), + TypeHintMatch( + function_name="fan_modes", + return_type=["list[str]", None], + ), + TypeHintMatch( + function_name="swing_mode", + return_type=["str", None], + ), + TypeHintMatch( + function_name="swing_modes", + return_type=["list[str]", None], + ), + TypeHintMatch( + function_name="set_temperature", + kwargs_type="Any", + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="set_humidity", + arg_types={ + 1: "int", + }, + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="set_fan_mode", + arg_types={ + 1: "str", + }, + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="set_hvac_mode", + arg_types={ + 1: "HVACMode", + }, + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="set_swing_mode", + arg_types={ + 1: "str", + }, + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="set_preset_mode", + arg_types={ + 1: "str", + }, + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="turn_aux_heat_on", + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="turn_aux_heat_off", + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="turn_on", + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="turn_off", + return_type="None", + has_async_counterpart=True, + ), + TypeHintMatch( + function_name="supported_features", + return_type="int", + ), + TypeHintMatch( + function_name="min_temp", + return_type="float", + ), + TypeHintMatch( + function_name="max_temp", + return_type="float", + ), + TypeHintMatch( + function_name="min_humidity", + return_type="int", + ), + TypeHintMatch( + function_name="max_humidity", + return_type="int", + ), + ], + ), + ], "cover": [ ClassTypeHintMatch( base_class="Entity",