From 88a7c76739d076ada1aec8886e187364841fcb8d Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Tue, 8 Nov 2022 17:16:31 +0200 Subject: [PATCH] Fix late-import paho (#81791) fix: late-import MQTTMessage `paho-mqtt` is not listed in main requirements and is imported early by `conftest`. Import it late to avoid an ImportError. Split out from #81678. --- homeassistant/components/mqtt/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index e909a378581..34384614c20 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -15,7 +15,6 @@ import uuid import attr import certifi -from paho.mqtt.client import MQTTMessage from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -620,7 +619,7 @@ class MQTT: ) def _mqtt_on_message( - self, _mqttc: mqtt.Client, _userdata: None, msg: MQTTMessage + self, _mqttc: mqtt.Client, _userdata: None, msg: mqtt.MQTTMessage ) -> None: """Message received callback.""" self.hass.add_job(self._mqtt_handle_message, msg) @@ -634,7 +633,7 @@ class MQTT: return subscriptions @callback - def _mqtt_handle_message(self, msg: MQTTMessage) -> None: + def _mqtt_handle_message(self, msg: mqtt.MQTTMessage) -> None: _LOGGER.debug( "Received%s message on %s: %s", " retained" if msg.retain else "",