Improve entity translation typing (#112788)
* Improve entity translation typing * Improve entity translation typingpull/112795/head
parent
a66399ad3d
commit
6a7c255b93
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue