Enforce CoverEntityFeature (#82457)

* Enforce CoverEntityFeature

* Adjust pylint
pull/82567/head
epenet 2022-11-22 07:09:19 +01:00 committed by GitHub
parent 48cc3071bb
commit 34607d4410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 17 additions and 17 deletions

View File

@ -70,9 +70,9 @@ class AcmedaCover(AcmedaBase, CoverEntity):
return position
@property
def supported_features(self) -> CoverEntityFeature | int:
def supported_features(self) -> CoverEntityFeature:
"""Flag supported features."""
supported_features = 0
supported_features = CoverEntityFeature(0)
if self.current_cover_position is not None:
supported_features |= (
CoverEntityFeature.OPEN

View File

@ -58,7 +58,7 @@ class BondCover(BondEntity, CoverEntity):
) -> None:
"""Create HA entity representing Bond cover."""
super().__init__(hub, device, bpup_subs)
supported_features = 0
supported_features = CoverEntityFeature(0)
if self._device.supports_set_position():
supported_features |= CoverEntityFeature.SET_POSITION
if self._device.supports_open():

View File

@ -232,7 +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
_attr_supported_features: CoverEntityFeature | None
_cover_is_last_toggle_direction_open = True
@ -292,7 +292,7 @@ class CoverEntity(Entity):
return data
@property
def supported_features(self) -> CoverEntityFeature | int:
def supported_features(self) -> CoverEntityFeature:
"""Flag supported features."""
if self._attr_supported_features is not None:
return self._attr_supported_features

View File

@ -324,7 +324,7 @@ class CoverGroup(GroupEntity, CoverEntity):
tilt_states, ATTR_CURRENT_TILT_POSITION
)
supported_features = 0
supported_features = CoverEntityFeature(0)
if self._covers[KEY_OPEN_CLOSE]:
supported_features |= CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
supported_features |= CoverEntityFeature.STOP if self._covers[KEY_STOP] else 0

View File

@ -118,7 +118,7 @@ class PowerViewShadeBase(ShadeEntity, CoverEntity):
"""Representation of a powerview shade."""
_attr_device_class = CoverDeviceClass.SHADE
_attr_supported_features = 0
_attr_supported_features = CoverEntityFeature(0)
def __init__(
self,

View File

@ -516,9 +516,9 @@ class MqttCover(MqttEntity, CoverEntity):
return self._config.get(CONF_DEVICE_CLASS)
@property
def supported_features(self) -> CoverEntityFeature | int:
def supported_features(self) -> CoverEntityFeature:
"""Flag supported features."""
supported_features = 0
supported_features = CoverEntityFeature(0)
if self._config.get(CONF_COMMAND_TOPIC) is not None:
if self._config.get(CONF_PAYLOAD_OPEN) is not None:
supported_features |= CoverEntityFeature.OPEN

View File

@ -25,9 +25,9 @@ class Awning(OverkizGenericCover):
_attr_device_class = CoverDeviceClass.AWNING
@property
def supported_features(self) -> int:
def supported_features(self) -> CoverEntityFeature:
"""Flag supported features."""
supported_features: int = super().supported_features
supported_features = super().supported_features
if self.executor.has_command(OverkizCommand.SET_DEPLOYMENT):
supported_features |= CoverEntityFeature.SET_POSITION

View File

@ -129,9 +129,9 @@ class OverkizGenericCover(OverkizEntity, CoverEntity):
return attr
@property
def supported_features(self) -> int:
def supported_features(self) -> CoverEntityFeature:
"""Flag supported features."""
supported_features = 0
supported_features = CoverEntityFeature(0)
if self.executor.has_command(*COMMANDS_OPEN_TILT):
supported_features |= CoverEntityFeature.OPEN_TILT

View File

@ -46,9 +46,9 @@ class VerticalCover(OverkizGenericCover):
"""Representation of an Overkiz vertical cover."""
@property
def supported_features(self) -> int:
def supported_features(self) -> CoverEntityFeature:
"""Flag supported features."""
supported_features: int = super().supported_features
supported_features = super().supported_features
if self.executor.has_command(OverkizCommand.SET_CLOSURE):
supported_features |= CoverEntityFeature.SET_POSITION

View File

@ -191,7 +191,7 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
super().__init__(device, device_manager)
self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"
self._attr_supported_features = 0
self._attr_supported_features = CoverEntityFeature(0)
# Check if this cover is based on a switch or has controls
if self.find_dpcode(description.key, prefer_function=True):

View File

@ -1110,7 +1110,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
),
TypeHintMatch(
function_name="supported_features",
return_type=["CoverEntityFeature", "int"],
return_type="CoverEntityFeature",
),
TypeHintMatch(
function_name="open_cover",