diff --git a/homeassistant/components/esphome/lock.py b/homeassistant/components/esphome/lock.py index 12666971d71..947ea4729bb 100644 --- a/homeassistant/components/esphome/lock.py +++ b/homeassistant/components/esphome/lock.py @@ -38,9 +38,11 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity): return self._static_info.assumed_state @property - def supported_features(self) -> LockEntityFeature | int: + def supported_features(self) -> LockEntityFeature: """Flag supported features.""" - return LockEntityFeature.OPEN if self._static_info.supports_open else 0 + if self._static_info.supports_open: + return LockEntityFeature.OPEN + return LockEntityFeature(0) @property def code_format(self) -> str | None: diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index 412e314da0f..5008fa0ca2b 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -112,7 +112,7 @@ class LockEntity(Entity): _attr_is_unlocking: bool | None = None _attr_is_jammed: bool | None = None _attr_state: None = None - _attr_supported_features: LockEntityFeature | int = 0 + _attr_supported_features: LockEntityFeature = LockEntityFeature(0) @property def changed_by(self) -> str | None: @@ -193,6 +193,6 @@ class LockEntity(Entity): return STATE_LOCKED if locked else STATE_UNLOCKED @property - def supported_features(self) -> LockEntityFeature | int: + def supported_features(self) -> LockEntityFeature: """Return the list of supported features.""" return self._attr_supported_features diff --git a/homeassistant/components/mqtt/lock.py b/homeassistant/components/mqtt/lock.py index ec1a3f2a897..525d85b5a6c 100644 --- a/homeassistant/components/mqtt/lock.py +++ b/homeassistant/components/mqtt/lock.py @@ -136,9 +136,9 @@ class MqttLock(MqttEntity, LockEntity): entity=self, ).async_render_with_possible_json_value - self._attr_supported_features = ( - LockEntityFeature.OPEN if CONF_PAYLOAD_OPEN in config else 0 - ) + self._attr_supported_features = LockEntityFeature(0) + if CONF_PAYLOAD_OPEN in config: + self._attr_supported_features |= LockEntityFeature.OPEN def _prepare_subscribe_topics(self) -> None: """(Re)Subscribe to topics.""" diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index a7c8782197f..e2e889e71b3 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1583,7 +1583,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ), TypeHintMatch( function_name="supported_features", - return_type=["LockEntityFeature", "int"], + return_type="LockEntityFeature", ), TypeHintMatch( function_name="lock",