From 2630ff8fce6bf4b36082b29af907c3bca4d6b642 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 16 Aug 2022 19:22:15 +0200 Subject: [PATCH] Add sensor checks to pylint plugin (#76876) --- pylint/plugins/hass_enforce_type_hints.py | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 35862742b18..e9147fcca70 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1863,6 +1863,46 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ], ), ], + "sensor": [ + ClassTypeHintMatch( + base_class="Entity", + matches=_ENTITY_MATCH, + ), + ClassTypeHintMatch( + base_class="SensorEntity", + matches=[ + TypeHintMatch( + function_name="device_class", + return_type=["SensorDeviceClass", "str", None], + ), + TypeHintMatch( + function_name="state_class", + return_type=["SensorStateClass", "str", None], + ), + TypeHintMatch( + function_name="last_reset", + return_type=["datetime", None], + ), + TypeHintMatch( + function_name="native_value", + return_type=[ + "StateType", + "str", + "int", + "float", + None, + "date", + "datetime", + "Decimal", + ], + ), + TypeHintMatch( + function_name="native_unit_of_measurement", + return_type=["str", None], + ), + ], + ), + ], "siren": [ ClassTypeHintMatch( base_class="Entity",