diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 767b24a67a6..137d9075b65 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -610,7 +610,7 @@ class Entity( def _device_class_name_helper( self, - component_translations: dict[str, Any], + component_translations: dict[str, str], ) -> str | None: """Return a translated name of the entity based on its device class.""" if not self.has_entity_name: @@ -675,7 +675,7 @@ class Entity( def _name_internal( self, device_class_name: str | None, - platform_translations: dict[str, Any], + platform_translations: dict[str, str], ) -> str | UndefinedType | None: """Return the name of the entity.""" if hasattr(self, "_attr_name"): @@ -685,8 +685,6 @@ class Entity( and (name_translation_key := self._name_translation_key) and (name := platform_translations.get(name_translation_key)) ): - if TYPE_CHECKING: - assert isinstance(name, str) return self._substitute_name_placeholders(name) if hasattr(self, "entity_description"): description_name = self.entity_description.name diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 299b8c214b3..cc829cc9bd2 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -130,10 +130,10 @@ class EntityPlatform: # Storage for entities for this specific platform only # which are indexed by entity_id self.entities: dict[str, Entity] = {} - self.component_translations: dict[str, Any] = {} - self.platform_translations: dict[str, Any] = {} - self.object_id_component_translations: dict[str, Any] = {} - self.object_id_platform_translations: dict[str, Any] = {} + self.component_translations: dict[str, str] = {} + self.platform_translations: dict[str, str] = {} + self.object_id_component_translations: dict[str, str] = {} + self.object_id_platform_translations: dict[str, str] = {} self._tasks: list[asyncio.Task[None]] = [] # Stop tracking tasks after setup is completed self._setup_complete = False @@ -419,7 +419,7 @@ class EntityPlatform: async def _async_get_translations( self, language: str, category: str, integration: str - ) -> dict[str, Any]: + ) -> dict[str, str]: """Get translations for a language, category, and integration.""" try: return await translation.async_get_translations(