diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index 072710aa947..98bb2f4909f 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -218,7 +218,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: class CoverEntityDescription(EntityDescription): """A class that describes cover entities.""" - device_class: CoverDeviceClass | str | None = None + device_class: CoverDeviceClass | None = None class CoverEntity(Entity): @@ -227,7 +227,7 @@ class CoverEntity(Entity): entity_description: CoverEntityDescription _attr_current_cover_position: int | None = None _attr_current_cover_tilt_position: int | None = None - _attr_device_class: CoverDeviceClass | str | None + _attr_device_class: CoverDeviceClass | None _attr_is_closed: bool | None _attr_is_closing: bool | None = None _attr_is_opening: bool | None = None @@ -253,7 +253,7 @@ class CoverEntity(Entity): return self._attr_current_cover_tilt_position @property - def device_class(self) -> CoverDeviceClass | str | None: + def device_class(self) -> CoverDeviceClass | None: """Return the class of this entity.""" if hasattr(self, "_attr_device_class"): return self._attr_device_class diff --git a/homeassistant/components/homematicip_cloud/cover.py b/homeassistant/components/homematicip_cloud/cover.py index 7038c423df0..e5007b5a15f 100644 --- a/homeassistant/components/homematicip_cloud/cover.py +++ b/homeassistant/components/homematicip_cloud/cover.py @@ -69,7 +69,7 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity): """Representation of the HomematicIP blind module.""" @property - def device_class(self) -> str: + def device_class(self) -> CoverDeviceClass: """Return the class of the cover.""" return CoverDeviceClass.BLIND @@ -162,7 +162,7 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity): ) @property - def device_class(self) -> str: + def device_class(self) -> CoverDeviceClass: """Return the class of the cover.""" return CoverDeviceClass.SHUTTER @@ -284,7 +284,7 @@ class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity): return door_state_to_position.get(self._device.doorState) @property - def device_class(self) -> str: + def device_class(self) -> CoverDeviceClass: """Return the class of the cover.""" return CoverDeviceClass.GARAGE @@ -315,7 +315,7 @@ class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity): super().__init__(hap, device, post, is_multi_channel=False) @property - def device_class(self) -> str: + def device_class(self) -> CoverDeviceClass: """Return the class of the cover.""" return CoverDeviceClass.SHUTTER diff --git a/homeassistant/components/netatmo/cover.py b/homeassistant/components/netatmo/cover.py index 6d755d828d3..41bf84c8334 100644 --- a/homeassistant/components/netatmo/cover.py +++ b/homeassistant/components/netatmo/cover.py @@ -99,7 +99,7 @@ class NetatmoCover(NetatmoBase, CoverEntity): await self._cover.async_set_target_position(kwargs[ATTR_POSITION]) @property - def device_class(self) -> str: + def device_class(self) -> CoverDeviceClass: """Return the device class.""" return CoverDeviceClass.SHUTTER diff --git a/homeassistant/components/overkiz/cover_entities/vertical_cover.py b/homeassistant/components/overkiz/cover_entities/vertical_cover.py index 1459786c23f..18a9f176593 100644 --- a/homeassistant/components/overkiz/cover_entities/vertical_cover.py +++ b/homeassistant/components/overkiz/cover_entities/vertical_cover.py @@ -65,15 +65,12 @@ class VerticalCover(OverkizGenericCover): return supported_features @property - def device_class(self) -> str: + def device_class(self) -> CoverDeviceClass: """Return the class of the device.""" - return cast( - str, - ( - OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.widget) - or OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.ui_class) - or CoverDeviceClass.BLIND - ), + return ( + OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.widget) + or OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.ui_class) + or CoverDeviceClass.BLIND ) @property diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 24f06bc8cd1..5925c833b29 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1086,7 +1086,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { matches=[ TypeHintMatch( function_name="device_class", - return_type=["CoverDeviceClass", "str", None], + return_type=["CoverDeviceClass", None], ), TypeHintMatch( function_name="current_cover_position", diff --git a/tests/pylint/test_enforce_type_hints.py b/tests/pylint/test_enforce_type_hints.py index 9abd2c89a74..665a4d6594c 100644 --- a/tests/pylint/test_enforce_type_hints.py +++ b/tests/pylint/test_enforce_type_hints.py @@ -898,7 +898,7 @@ def test_invalid_device_class( pylint.testutils.MessageTest( msg_id="hass-return-type", node=prop_node, - args=(["CoverDeviceClass", "str", None], "device_class"), + args=(["CoverDeviceClass", None], "device_class"), line=12, col_offset=4, end_line=12,