Adjust type hints for CoverEntityFeature (#82238)
This commit is contained in:
parent
6856374f24
commit
17573196c8
10 changed files with 15 additions and 10 deletions
|
@ -70,7 +70,7 @@ class AcmedaCover(AcmedaBase, CoverEntity):
|
|||
return position
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature | int:
|
||||
"""Flag supported features."""
|
||||
supported_features = 0
|
||||
if self.current_cover_position is not None:
|
||||
|
|
|
@ -232,6 +232,7 @@ class CoverEntity(Entity):
|
|||
_attr_is_closing: bool | None = None
|
||||
_attr_is_opening: bool | None = None
|
||||
_attr_state: None = None
|
||||
_attr_supported_features: CoverEntityFeature | int | None
|
||||
|
||||
_cover_is_last_toggle_direction_open = True
|
||||
|
||||
|
@ -291,7 +292,7 @@ class CoverEntity(Entity):
|
|||
return data
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature | int:
|
||||
"""Flag supported features."""
|
||||
if self._attr_supported_features is not None:
|
||||
return self._attr_supported_features
|
||||
|
|
|
@ -38,7 +38,7 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
|
|||
"""A cover implementation for ESPHome."""
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature:
|
||||
"""Flag supported features."""
|
||||
flags = (
|
||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||
|
|
|
@ -143,7 +143,7 @@ class HomeKitWindowCover(HomeKitEntity, CoverEntity):
|
|||
]
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature:
|
||||
"""Flag supported features."""
|
||||
features = (
|
||||
CoverEntityFeature.OPEN
|
||||
|
|
|
@ -380,7 +380,7 @@ class MotionTiltOnlyDevice(MotionTiltDevice):
|
|||
_restore_tilt = False
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature:
|
||||
"""Flag supported features."""
|
||||
supported_features = (
|
||||
CoverEntityFeature.OPEN_TILT
|
||||
|
|
|
@ -535,7 +535,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||
return self._config.get(CONF_DEVICE_CLASS)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature | int:
|
||||
"""Flag supported features."""
|
||||
supported_features = 0
|
||||
if self._config.get(CONF_COMMAND_TOPIC) is not None:
|
||||
|
|
|
@ -75,7 +75,7 @@ class BlockShellyCover(ShellyBlockEntity, CoverEntity):
|
|||
"""Initialize block cover."""
|
||||
super().__init__(coordinator, block)
|
||||
self.control_result: dict[str, Any] | None = None
|
||||
self._attr_supported_features: int = (
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||
)
|
||||
if self.coordinator.device.settings["rollers"][0]["positioning"]:
|
||||
|
@ -151,7 +151,7 @@ class RpcShellyCover(ShellyRpcEntity, CoverEntity):
|
|||
"""Initialize rpc cover."""
|
||||
super().__init__(coordinator, f"cover:{id_}")
|
||||
self._id = id_
|
||||
self._attr_supported_features: int = (
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||
)
|
||||
if self.status["pos_control"]:
|
||||
|
|
|
@ -309,7 +309,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
|
|||
return self._device_class
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature:
|
||||
"""Flag supported features."""
|
||||
supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class VeluxCover(VeluxEntity, CoverEntity):
|
|||
"""Representation of a Velux cover."""
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
def supported_features(self) -> CoverEntityFeature:
|
||||
"""Flag supported features."""
|
||||
supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
|
|
|
@ -1108,6 +1108,10 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||
function_name="is_closed",
|
||||
return_type=["bool", None],
|
||||
),
|
||||
TypeHintMatch(
|
||||
function_name="supported_features",
|
||||
return_type=["CoverEntityFeature", "int"],
|
||||
),
|
||||
TypeHintMatch(
|
||||
function_name="open_cover",
|
||||
kwargs_type="Any",
|
||||
|
|
Loading…
Add table
Reference in a new issue