Mark light methods and properties as mandatory in pylint plugin (#145510)

This commit is contained in:
epenet 2025-05-23 15:28:41 +02:00 committed by GitHub
parent bca4793c69
commit 528a509479
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 6 deletions

View File

@ -84,7 +84,7 @@ class BleBoxLightEntity(BleBoxEntity[blebox_uniapi.light.Light], LightEntity):
return color_util.color_temperature_mired_to_kelvin(self._feature.color_temp)
@property
def color_mode(self):
def color_mode(self) -> ColorMode:
"""Return the color mode.
Set values to _attr_ibutes if needed.
@ -92,7 +92,7 @@ class BleBoxLightEntity(BleBoxEntity[blebox_uniapi.light.Light], LightEntity):
return COLOR_MODE_MAP.get(self._feature.color_mode, ColorMode.ONOFF)
@property
def supported_color_modes(self):
def supported_color_modes(self) -> set[ColorMode]:
"""Return supported color modes."""
return {self.color_mode}
@ -107,7 +107,7 @@ class BleBoxLightEntity(BleBoxEntity[blebox_uniapi.light.Light], LightEntity):
return self._feature.effect
@property
def rgb_color(self):
def rgb_color(self) -> tuple[int, int, int] | None:
"""Return value for rgb."""
if (rgb_hex := self._feature.rgb_hex) is None:
return None
@ -118,14 +118,14 @@ class BleBoxLightEntity(BleBoxEntity[blebox_uniapi.light.Light], LightEntity):
)
@property
def rgbw_color(self):
def rgbw_color(self) -> tuple[int, int, int, int] | None:
"""Return the hue and saturation."""
if (rgbw_hex := self._feature.rgbw_hex) is None:
return None
return tuple(blebox_uniapi.light.Light.rgb_hex_to_rgb_list(rgbw_hex)[0:4])
@property
def rgbww_color(self):
def rgbww_color(self) -> tuple[int, int, int, int, int] | None:
"""Return value for rgbww."""
if (rgbww_hex := self._feature.rgbww_hex) is None:
return None

View File

@ -841,7 +841,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb):
return self._hs_color
@property
def color_mode(self):
def color_mode(self) -> ColorMode:
"""Return the color mode of the light."""
if self.hs_color:
return ColorMode.HS

View File

@ -1816,6 +1816,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
TypeHintMatch(
function_name="color_mode",
return_type=["ColorMode", "str", None],
mandatory=True,
),
TypeHintMatch(
function_name="hs_color",
@ -1828,26 +1829,32 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
TypeHintMatch(
function_name="rgb_color",
return_type=["tuple[int, int, int]", None],
mandatory=True,
),
TypeHintMatch(
function_name="rgbw_color",
return_type=["tuple[int, int, int, int]", None],
mandatory=True,
),
TypeHintMatch(
function_name="rgbww_color",
return_type=["tuple[int, int, int, int, int]", None],
mandatory=True,
),
TypeHintMatch(
function_name="color_temp",
return_type=["int", None],
mandatory=True,
),
TypeHintMatch(
function_name="min_mireds",
return_type="int",
mandatory=True,
),
TypeHintMatch(
function_name="max_mireds",
return_type="int",
mandatory=True,
),
TypeHintMatch(
function_name="effect_list",
@ -1864,10 +1871,12 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
TypeHintMatch(
function_name="supported_color_modes",
return_type=["set[ColorMode]", "set[str]", None],
mandatory=True,
),
TypeHintMatch(
function_name="supported_features",
return_type="LightEntityFeature",
mandatory=True,
),
TypeHintMatch(
function_name="turn_on",
@ -1892,6 +1901,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
kwargs_type="Any",
return_type=None,
has_async_counterpart=True,
mandatory=True,
),
],
),