Adjust type hints for SirenEntityFeature (#82266)

This commit is contained in:
epenet 2022-11-17 15:06:26 +01:00 committed by GitHub
parent 9b9bdc725f
commit 295cd0143c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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"],
),
],
),
],