Adjust type hints for LockEntityFeature (#82256)
This commit is contained in:
parent
4986f65dca
commit
8570d3aabe
4 changed files with 11 additions and 2 deletions
|
@ -60,7 +60,6 @@ class DemoLock(LockEntity):
|
|||
) -> None:
|
||||
"""Initialize the lock."""
|
||||
self._attr_name = name
|
||||
self._attr_supported_features = 0
|
||||
if openable:
|
||||
self._attr_supported_features = LockEntityFeature.OPEN
|
||||
self._state = state
|
||||
|
|
|
@ -38,7 +38,7 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity):
|
|||
return self._static_info.assumed_state
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> LockEntityFeature | int:
|
||||
"""Flag supported features."""
|
||||
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_jammed: bool | None = None
|
||||
_attr_state: None = None
|
||||
_attr_supported_features: LockEntityFeature | int = 0
|
||||
|
||||
@property
|
||||
def changed_by(self) -> str | None:
|
||||
|
@ -190,3 +191,8 @@ class LockEntity(Entity):
|
|||
if (locked := self.is_locked) is None:
|
||||
return None
|
||||
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",
|
||||
return_type=["bool", None],
|
||||
),
|
||||
TypeHintMatch(
|
||||
function_name="supported_features",
|
||||
return_type=["LockEntityFeature", "int"],
|
||||
),
|
||||
TypeHintMatch(
|
||||
function_name="lock",
|
||||
kwargs_type="Any",
|
||||
|
|
Loading…
Add table
Reference in a new issue