From 1590549e5b01ea292ec7bf763777bc415f0d320d Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 6 Oct 2026 08:41:31 +0200 Subject: [PATCH] Replace unreachable MQTT discovery teardown guard with TYPE_CHECKING assert (#183913) Co-authored-by: Claude Opus 5.5 --- homeassistant/components/mqtt/entity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/mqtt/entity.py b/homeassistant/components/mqtt/entity.py index 181739d9c6b8..8ceab51cfc27 100644 --- a/homeassistant/components/mqtt/entity.py +++ b/homeassistant/components/mqtt/entity.py @@ -1261,8 +1261,8 @@ class MqttDiscoveryUpdateMixin(Entity): disabled entity), a registry hook is installed so the retained discovery topic is cleared if the entity is later removed from the registry. """ - if self._discovery_data is None: - return + if TYPE_CHECKING: + assert self._discovery_data is not None if not self._added_to_hass and self.registry_entry is not None: discovery_hash: tuple[str, str] = self._discovery_data[ATTR_DISCOVERY_HASH] self._registry_hooks[discovery_hash] = (