@@ -60,7 +60,11 @@ def __init__(
6060
6161 # Create a client to connect to RabbitMQ
6262 # TODO clean_session param is ONLY for MQTT v3 here
63- self ._connection = paho_client .Client (client_id = self .uid , clean_session = False )
63+ self ._connection = paho_client .Client (
64+ callback_api_version = paho_client .CallbackAPIVersion .VERSION2 ,
65+ client_id = self .uid ,
66+ clean_session = False ,
67+ )
6468 self ._connection .username_pw_set (username = username , password = password )
6569
6670 # Whether the connection is currently active
@@ -141,36 +145,53 @@ def unsubscribe(self, topic: str) -> None:
141145 self ._connection .unsubscribe (topic )
142146
143147 def _on_message (
144- self , _client : paho_client .Client , _userdata : Any , message : paho_client .MQTTMessage
148+ self ,
149+ client : paho_client .Client , # noqa: ARG002
150+ userdata : Any , # noqa: ARG002
151+ message : paho_client .MQTTMessage ,
145152 ) -> None :
146153 """Handle a message from the MQTT server.
147154
148155 Args:
149- _client : the Paho client
150- _userdata : MQTT user data
156+ client : the Paho client
157+ userdata : MQTT user data
151158 message: MQTT message
152159 """
153160 topic_handler = self ._topics_to_handlers ().get (message .topic )
154161 if topic_handler :
155162 for cb in topic_handler .callbacks :
156163 cb (message .payload )
157164
158- def _handle_disconnect (self , client : paho_client .Client , _userdata : Any , _rc : int ) -> None :
165+ def _handle_disconnect (
166+ self ,
167+ client : paho_client .Client ,
168+ userdata : Any , # noqa: ARG002
169+ flags : dict [str , Any ], # noqa: ARG002
170+ reason_code : int , # noqa: ARG002
171+ properties : None , # noqa: ARG002
172+ ) -> None :
159173 """Handle a disconnection from the MQTT server.
160174
161175 This callback usually implies a temporary connection fault, so we'll try to handle it.
162176
163177 Args:
164178 client: The Paho client.
165- _userdata: MQTT user data.
166- rc: MQTT return code as an integer.
179+ userdata: MQTT user data.
180+ flags: List of MQTT connection flags.
181+ reason_code: MQTT return code as an integer.
182+ properties: MQTT user properties.
167183 """
168184 self ._connected = False
169185 if not self ._should_disconnect :
170186 client .reconnect ()
171187
172188 def _handle_connect (
173- self , _client : paho_client .Client , userdata : Any , flags : dict [str , Any ], rc : int
189+ self ,
190+ client : paho_client .Client , # noqa: ARG002
191+ userdata : Any ,
192+ flags : dict [str , Any ],
193+ reason_code : int ,
194+ properties : None , # noqa: ARG002
174195 ) -> None :
175196 """Set the connection status in response to the result of a Paho connection attempt.
176197
@@ -181,10 +202,11 @@ def _handle_connect(
181202 client: The Paho MQTT client.
182203 userdata: The MQTT userdata.
183204 flags: List of MQTT connection flags.
184- rc: The MQTT return code as an int.
205+ reason_code: The MQTT return code as an int.
206+ properties: MQTT user properties
185207 """
186208 # Return code 0 means connection was successful
187- if rc == 0 :
209+ if reason_code == 0 :
188210 self ._connected = True
189211 self ._connection_retries = 0
190212 self ._should_disconnect = False
0 commit comments