Adjust type hints for LightEntityFeature (#82251)

This commit is contained in:
epenet 2022-11-17 12:46:42 +01:00 committed by GitHub
parent 8a084cf94d
commit dd7bc7971f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 14 additions and 14 deletions

View File

@ -192,7 +192,7 @@ class Control4Light(Control4Entity, LightEntity):
return None return None
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature | int:
"""Flag supported features.""" """Flag supported features."""
if self._is_dimmer: if self._is_dimmer:
return LightEntityFeature.TRANSITION return LightEntityFeature.TRANSITION

View File

@ -112,7 +112,7 @@ class DecoraWifiLight(LightEntity):
return {self.color_mode} return {self.color_mode}
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature | int:
"""Return supported features.""" """Return supported features."""
if self._switch.canSetLevel: if self._switch.canSetLevel:
return LightEntityFeature.TRANSITION return LightEntityFeature.TRANSITION

View File

@ -347,9 +347,9 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
return self._static_info.supported_color_modes_compat(self._api_version) return self._static_info.supported_color_modes_compat(self._api_version)
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature:
"""Flag supported features.""" """Flag supported features."""
flags: int = LightEntityFeature.FLASH flags = LightEntityFeature.FLASH
# All color modes except UNKNOWN,ON_OFF support transition # All color modes except UNKNOWN,ON_OFF support transition
modes = self._native_supported_color_modes modes = self._native_supported_color_modes

View File

@ -82,9 +82,9 @@ class HMLight(HMDevice, LightEntity):
return color_modes return color_modes
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature:
"""Flag supported features.""" """Flag supported features."""
features: int = LightEntityFeature.TRANSITION features = LightEntityFeature.TRANSITION
if "PROGRAM" in self._hmdevice.WRITENODE: if "PROGRAM" in self._hmdevice.WRITENODE:
features |= LightEntityFeature.EFFECT features |= LightEntityFeature.EFFECT
return features return features

View File

@ -100,7 +100,7 @@ class HassAqualinkLight(AqualinkEntity, LightEntity):
return {self.color_mode} return {self.color_mode}
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature | int:
"""Return the list of features supported by the light.""" """Return the list of features supported by the light."""
if self.dev.supports_effect: if self.dev.supports_effect:
return LightEntityFeature.EFFECT return LightEntityFeature.EFFECT

View File

@ -793,7 +793,7 @@ class LightEntity(ToggleEntity):
_attr_rgbw_color: tuple[int, int, int, int] | None = None _attr_rgbw_color: tuple[int, int, int, int] | None = None
_attr_rgbww_color: tuple[int, int, int, int, int] | None = None _attr_rgbww_color: tuple[int, int, int, int, int] | None = None
_attr_supported_color_modes: set[ColorMode] | set[str] | None = None _attr_supported_color_modes: set[ColorMode] | set[str] | None = None
_attr_supported_features: int = 0 _attr_supported_features: LightEntityFeature | int = 0
_attr_xy_color: tuple[float, float] | None = None _attr_xy_color: tuple[float, float] | None = None
@property @property
@ -1060,6 +1060,6 @@ class LightEntity(ToggleEntity):
return self._attr_supported_color_modes return self._attr_supported_color_modes
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature | int:
"""Flag supported features.""" """Flag supported features."""
return self._attr_supported_features return self._attr_supported_features

View File

@ -101,7 +101,7 @@ class SmartThingsLight(SmartThingsEntity, LightEntity):
return color_modes return color_modes
def _determine_features(self): def _determine_features(self) -> LightEntityFeature | int:
"""Get features supported by the device.""" """Get features supported by the device."""
features = 0 features = 0
# Transition # Transition

View File

@ -254,7 +254,7 @@ class LightTemplate(TemplateEntity, LightEntity):
return self._supported_color_modes return self._supported_color_modes
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature | int:
"""Flag supported features.""" """Flag supported features."""
supported_features = 0 supported_features = 0
if self._effect_script is not None: if self._effect_script is not None:

View File

@ -312,7 +312,7 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
device: SmartLightStrip device: SmartLightStrip
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature | int:
"""Flag supported features.""" """Flag supported features."""
return super().supported_features | LightEntityFeature.EFFECT return super().supported_features | LightEntityFeature.EFFECT

View File

@ -71,7 +71,7 @@ class UpbLight(UpbAttachedEntity, LightEntity):
return {self.color_mode} return {self.color_mode}
@property @property
def supported_features(self) -> int: def supported_features(self) -> LightEntityFeature:
"""Flag supported features.""" """Flag supported features."""
if self._element.dimmable: if self._element.dimmable:
return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH

View File

@ -1520,7 +1520,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
), ),
TypeHintMatch( TypeHintMatch(
function_name="supported_features", function_name="supported_features",
return_type="int", return_type=["LightEntityFeature", "int"],
), ),
TypeHintMatch( TypeHintMatch(
function_name="turn_on", function_name="turn_on",