diff --git a/homeassistant/components/lookin/media_player.py b/homeassistant/components/lookin/media_player.py index 405852e88a6..f7ae457cbff 100644 --- a/homeassistant/components/lookin/media_player.py +++ b/homeassistant/components/lookin/media_player.py @@ -79,7 +79,7 @@ class LookinMedia(LookinPowerPushRemoteEntity, MediaPlayerEntity): uuid: str, device: Remote, lookin_data: LookinData, - device_class: str, + device_class: MediaPlayerDeviceClass, ) -> None: """Init the lookin media player.""" self._attr_device_class = device_class diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index 2337990933a..ffe0b4e2813 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -453,7 +453,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: class MediaPlayerEntityDescription(EntityDescription): """A class that describes media player entities.""" - device_class: MediaPlayerDeviceClass | str | None = None + device_class: MediaPlayerDeviceClass | None = None class MediaPlayerEntity(Entity): @@ -464,7 +464,7 @@ class MediaPlayerEntity(Entity): _attr_app_id: str | None = None _attr_app_name: str | None = None - _attr_device_class: MediaPlayerDeviceClass | str | None + _attr_device_class: MediaPlayerDeviceClass | None _attr_group_members: list[str] | None = None _attr_is_volume_muted: bool | None = None _attr_media_album_artist: str | None = None @@ -497,7 +497,7 @@ class MediaPlayerEntity(Entity): # Implement these for your media player @property - def device_class(self) -> MediaPlayerDeviceClass | str | None: + def device_class(self) -> MediaPlayerDeviceClass | None: """Return the class of this entity.""" if hasattr(self, "_attr_device_class"): return self._attr_device_class diff --git a/homeassistant/components/roku/media_player.py b/homeassistant/components/roku/media_player.py index 7b495247c4d..b09ddb7ef7d 100644 --- a/homeassistant/components/roku/media_player.py +++ b/homeassistant/components/roku/media_player.py @@ -130,7 +130,7 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity): return self.coordinator.data.media.duration > 0 @property - def device_class(self) -> str | None: + def device_class(self) -> MediaPlayerDeviceClass: """Return the class of this device.""" if self.coordinator.data.info.device_type == "tv": return MediaPlayerDeviceClass.TV diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index 3c6ba701f7d..4f0e17cac9b 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -40,6 +40,7 @@ from homeassistant.components.media_player import ( SERVICE_PLAY_MEDIA, SERVICE_SELECT_SOUND_MODE, SERVICE_SELECT_SOURCE, + MediaPlayerDeviceClass, MediaPlayerEntity, MediaPlayerEntityFeature, MediaPlayerState, @@ -279,7 +280,7 @@ class UniversalMediaPlayer(MediaPlayerEntity): ) @property - def device_class(self) -> str | None: + def device_class(self) -> MediaPlayerDeviceClass | None: """Return the class of this device.""" return self._device_class diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index a418399b450..e159a110334 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1649,7 +1649,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { matches=[ TypeHintMatch( function_name="device_class", - return_type=["MediaPlayerDeviceClass", "str", None], + return_type=["MediaPlayerDeviceClass", None], ), TypeHintMatch( function_name="state",