Skip to content

Commit 8d1b6a1

Browse files
author
brentru
committed
black and pylint it up!
1 parent 0223a92 commit 8d1b6a1

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"""
4343
import struct
4444
import time
45-
import gc
4645
from random import randint
4746
from micropython import const
4847
import adafruit_logging as logging
@@ -411,7 +410,7 @@ def ping(self):
411410
raise MMQTTException("PINGRESP not returned from broker.")
412411
return
413412

414-
# pylint: disable=too-many-branches, too-many-statements
413+
# pylint: disable=too-many-branches, too-many-statements
415414
def publish(self, topic, msg, retain=False, qos=0):
416415
"""Publishes a message to a topic provided.
417416
:param str topic: Unique topic identifier.
@@ -447,14 +446,14 @@ def publish(self, topic, msg, retain=False, qos=0):
447446
raise MMQTTException("Message size larger than %d bytes." % MQTT_MSG_MAX_SZ)
448447
self._check_qos(qos)
449448

450-
pub_hdr_fixed = bytearray() # fixed header
449+
pub_hdr_fixed = bytearray() # fixed header
451450
pub_hdr_fixed.extend(MQTT_PUB)
452-
pub_hdr_fixed[0] |= retain | qos << 1
451+
pub_hdr_fixed[0] |= retain | qos << 1
453452

454-
pub_hdr_var = bytearray() # variable header
455-
pub_hdr_var.append(len(topic) >> 8) # Topic len MSB
456-
pub_hdr_var.append(len(topic) & 0xFF) # Topic len LSB
457-
pub_hdr_var.extend(topic.encode("utf-8")) # Topic structure
453+
pub_hdr_var = bytearray() # variable header
454+
pub_hdr_var.append(len(topic) >> 8) # Topic len MSB
455+
pub_hdr_var.append(len(topic) & 0xFF) # Topic len LSB
456+
pub_hdr_var.extend(topic.encode("utf-8")) # Topic structure
458457

459458
remaining_length = 2 + len(msg) + len(topic)
460459
if qos > 0:
@@ -465,7 +464,7 @@ def publish(self, topic, msg, retain=False, qos=0):
465464
self._pid += 1
466465

467466
# Remaining length calculation
468-
if remaining_length > 0x7f:
467+
if remaining_length > 0x7F:
469468
# Calculate Remaining Length [2.2.3]
470469
while remaining_length > 0:
471470
encoded_byte = remaining_length % 0x80
@@ -488,7 +487,7 @@ def publish(self, topic, msg, retain=False, qos=0):
488487
self._sock.send(pub_hdr_var)
489488
self._sock.send(msg)
490489
if qos == 0 and self.on_publish is not None:
491-
self.on_publish(self, self.user_data, topic, self._pid)
490+
self.on_publish(self, self.user_data, topic, self._pid)
492491
if qos == 1:
493492
while True:
494493
op = self._wait_for_msg()
@@ -833,4 +832,4 @@ def set_logger_level(self, log_level):
833832
elif log_level == "ERROR":
834833
self.logger.setLevel(logging.CRITICIAL)
835834
else:
836-
raise MMQTTException("Incorrect logging level provided!")
835+
raise MMQTTException("Incorrect logging level provided!")

0 commit comments

Comments
 (0)