diff --git a/homeassistant/components/esphome/light.py b/homeassistant/components/esphome/light.py index 67b8e755c87..ca08768fb2a 100644 --- a/homeassistant/components/esphome/light.py +++ b/homeassistant/components/esphome/light.py @@ -300,7 +300,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity): @property @esphome_state_property - def color_mode(self) -> str: + def color_mode(self) -> ColorMode: """Return the color mode of the light.""" if not self._supports_color_mode: supported_color_modes = self.supported_color_modes diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index d2869670ba4..8035e47a72b 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -123,8 +123,8 @@ def filter_supported_color_modes(color_modes: Iterable[ColorMode]) -> set[ColorM def valid_supported_color_modes( - color_modes: Iterable[ColorMode | str], -) -> set[ColorMode | str]: + color_modes: Iterable[ColorMode], +) -> set[ColorMode]: """Validate the given color modes.""" color_modes = set(color_modes) if ( @@ -902,7 +902,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): entity_description: LightEntityDescription _attr_brightness: int | None = None - _attr_color_mode: ColorMode | str | None = None + _attr_color_mode: ColorMode | None = None _attr_color_temp_kelvin: int | None = None _attr_effect_list: list[str] | None = None _attr_effect: str | None = None @@ -915,7 +915,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): _attr_rgb_color: tuple[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_supported_color_modes: set[ColorMode] | set[str] | None = None + _attr_supported_color_modes: set[ColorMode] | None = None _attr_supported_features: LightEntityFeature = LightEntityFeature(0) _attr_xy_color: tuple[float, float] | None = None @@ -932,7 +932,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): return self._attr_brightness @cached_property - def color_mode(self) -> ColorMode | str | None: + def color_mode(self) -> ColorMode | None: """Return the color mode of the light.""" return self._attr_color_mode @@ -1233,7 +1233,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def __validate_supported_color_modes( self, - supported_color_modes: set[ColorMode] | set[str], + supported_color_modes: set[ColorMode], ) -> None: """Validate the supported color modes.""" if self.__color_mode_reported: @@ -1339,7 +1339,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): return data @property - def _light_internal_supported_color_modes(self) -> set[ColorMode] | set[str]: + def _light_internal_supported_color_modes(self) -> set[ColorMode]: """Calculate supported color modes with backwards compatibility.""" if (_supported_color_modes := self.supported_color_modes) is not None: self.__validate_supported_color_modes(_supported_color_modes) @@ -1379,7 +1379,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): return supported_color_modes @cached_property - def supported_color_modes(self) -> set[ColorMode] | set[str] | None: + def supported_color_modes(self) -> set[ColorMode] | None: """Flag supported color modes.""" return self._attr_supported_color_modes diff --git a/homeassistant/components/limitlessled/light.py b/homeassistant/components/limitlessled/light.py index 48aa902c46b..4e28f166269 100644 --- a/homeassistant/components/limitlessled/light.py +++ b/homeassistant/components/limitlessled/light.py @@ -275,7 +275,7 @@ class LimitlessLEDGroup(LightEntity, RestoreEntity): return self._attr_brightness @property - def color_mode(self) -> str | None: + def color_mode(self) -> ColorMode: """Return the color mode of the light.""" if self._fixed_color_mode: return self._fixed_color_mode diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 54b755fc98c..33e19167807 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1829,7 +1829,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ), TypeHintMatch( function_name="color_mode", - return_type=["ColorMode", "str", None], + return_type=["ColorMode", None], mandatory=True, ), TypeHintMatch( @@ -1884,7 +1884,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { ), TypeHintMatch( function_name="supported_color_modes", - return_type=["set[ColorMode]", "set[str]", None], + return_type=["set[ColorMode]", None], mandatory=True, ), TypeHintMatch(