mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Adjust type hints for LockEntityFeature (#82256)
This commit is contained in:
parent
4986f65dca
commit
8570d3aabe
@ -60,7 +60,6 @@ class DemoLock(LockEntity):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the lock."""
|
"""Initialize the lock."""
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
self._attr_supported_features = 0
|
|
||||||
if openable:
|
if openable:
|
||||||
self._attr_supported_features = LockEntityFeature.OPEN
|
self._attr_supported_features = LockEntityFeature.OPEN
|
||||||
self._state = state
|
self._state = state
|
||||||
|
@ -38,7 +38,7 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity):
|
|||||||
return self._static_info.assumed_state
|
return self._static_info.assumed_state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LockEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return LockEntityFeature.OPEN if self._static_info.supports_open else 0
|
return LockEntityFeature.OPEN if self._static_info.supports_open else 0
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ class LockEntity(Entity):
|
|||||||
_attr_is_unlocking: bool | None = None
|
_attr_is_unlocking: bool | None = None
|
||||||
_attr_is_jammed: bool | None = None
|
_attr_is_jammed: bool | None = None
|
||||||
_attr_state: None = None
|
_attr_state: None = None
|
||||||
|
_attr_supported_features: LockEntityFeature | int = 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def changed_by(self) -> str | None:
|
def changed_by(self) -> str | None:
|
||||||
@ -190,3 +191,8 @@ class LockEntity(Entity):
|
|||||||
if (locked := self.is_locked) is None:
|
if (locked := self.is_locked) is None:
|
||||||
return None
|
return None
|
||||||
return STATE_LOCKED if locked else STATE_UNLOCKED
|
return STATE_LOCKED if locked else STATE_UNLOCKED
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self) -> LockEntityFeature | int:
|
||||||
|
"""Return the list of supported features."""
|
||||||
|
return self._attr_supported_features
|
||||||
|
@ -1581,6 +1581,10 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||||||
function_name="is_jammed",
|
function_name="is_jammed",
|
||||||
return_type=["bool", None],
|
return_type=["bool", None],
|
||||||
),
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="supported_features",
|
||||||
|
return_type=["LockEntityFeature", "int"],
|
||||||
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="lock",
|
function_name="lock",
|
||||||
kwargs_type="Any",
|
kwargs_type="Any",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user