From 295cd0143c6870fd19033960619e7812b81a28b4 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 17 Nov 2022 15:06:26 +0100 Subject: [PATCH] Adjust type hints for SirenEntityFeature (#82266) --- homeassistant/components/mqtt/siren.py | 3 +-- homeassistant/components/siren/__init__.py | 6 ++++++ pylint/plugins/hass_enforce_type_hints.py | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/mqtt/siren.py b/homeassistant/components/mqtt/siren.py index 4a69977df45..8b622d207fa 100644 --- a/homeassistant/components/mqtt/siren.py +++ b/homeassistant/components/mqtt/siren.py @@ -171,7 +171,6 @@ class MqttSiren(MqttEntity, SirenEntity): _entity_id_format = ENTITY_ID_FORMAT _attributes_extra_blocked = MQTT_SIREN_ATTRIBUTES_BLOCKED - _attr_supported_features: int _command_templates: dict[ str, Callable[[PublishPayloadType, TemplateVarsType], PublishPayloadType] | None @@ -207,7 +206,7 @@ class MqttSiren(MqttEntity, SirenEntity): self._attr_extra_state_attributes = {} - _supported_features: int = SUPPORTED_BASE + _supported_features = SUPPORTED_BASE if config[CONF_SUPPORT_DURATION]: _supported_features |= SirenEntityFeature.DURATION self._attr_extra_state_attributes[ATTR_DURATION] = None diff --git a/homeassistant/components/siren/__init__.py b/homeassistant/components/siren/__init__.py index 920865c41f3..faf8caf8ed0 100644 --- a/homeassistant/components/siren/__init__.py +++ b/homeassistant/components/siren/__init__.py @@ -163,6 +163,7 @@ class SirenEntity(ToggleEntity): entity_description: SirenEntityDescription _attr_available_tones: list[int | str] | dict[int, str] | None + _attr_supported_features: SirenEntityFeature | int = 0 @final @property @@ -190,3 +191,8 @@ class SirenEntity(ToggleEntity): if hasattr(self, "entity_description"): return self.entity_description.available_tones return None + + @property + def supported_features(self) -> SirenEntityFeature | int: + """Return the list of supported features.""" + return self._attr_supported_features diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 1f372c6550d..b9247bbca27 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -2212,6 +2212,10 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { function_name="available_tones", return_type=["dict[int, str]", "list[int | str]", None], ), + TypeHintMatch( + function_name="supported_features", + return_type=["SirenEntityFeature", "int"], + ), ], ), ],