Avoid creating inner function in EntityComponent setup (#114050)

This commit is contained in:
J. Nick Koston 2024-03-23 11:31:23 -10:00 committed by GitHub
parent 4e03d9cd47
commit 1c1d8d0317
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -156,16 +156,16 @@ class EntityComponent(Generic[_EntityT]):
# Generic discovery listener for loading platform dynamically
# Refer to: homeassistant.helpers.discovery.async_load_platform()
async def component_platform_discovered(
platform: str, info: dict[str, Any] | None
) -> None:
"""Handle the loading of a platform."""
await self.async_setup_platform(platform, {}, info)
discovery.async_listen_platform(
self.hass, self.domain, component_platform_discovered
self.hass, self.domain, self._async_component_platform_discovered
)
async def _async_component_platform_discovered(
self, platform: str, info: dict[str, Any] | None
) -> None:
"""Handle the loading of a platform."""
await self.async_setup_platform(platform, {}, info)
async def async_setup_entry(self, config_entry: ConfigEntry) -> bool:
"""Set up a config entry."""
platform_type = config_entry.domain