From 345010137f057d5ee3f1ef093a1c9a5ceeb4a4ef Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Tue, 25 Aug 2020 01:43:18 +0000 Subject: [PATCH 1/6] AdaFruit Logging is required ```python Adafruit CircuitPython 5.0.0-beta.0-2634-gda61845f5-dirty on 2020-08-24; FeatherS2 with ESP32S2 >>> import os >>> os.listdir('/lib') ['adafruit_requests.mpy', 'adafruit_azureiot', '._adafruit_azureiot', 'adafruit_minimqtt', '._adafruit_minimqtt', 'adafruit_binascii.mpy', '._adafruit_binascii.mpy', 'adafruit_ntp.mpy', '._adafruit_ntp.mpy'] >>> import adafruit_minimqtt.adafruit_minimqtt as MINIQTT Traceback (most recent call last): File "", line 1, in File "adafruit_minimqtt/adafruit_minimqtt.py", line 47, in ImportError: no module named 'adafruit_logging' ``` --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index ec635da..8ee45df 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,7 @@ Dependencies This driver depends on: * `Adafruit CircuitPython `_ +* `Adafruit Logging `_ Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading From e06ce97373312eb65a3bceda1b8df0490a2b6f95 Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Tue, 25 Aug 2020 02:31:02 +0000 Subject: [PATCH 2/6] Fix Pylint Errors --- adafruit_minimqtt/matcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_minimqtt/matcher.py b/adafruit_minimqtt/matcher.py index 3f854fb..c91c1ad 100755 --- a/adafruit_minimqtt/matcher.py +++ b/adafruit_minimqtt/matcher.py @@ -55,7 +55,7 @@ def __getitem__(self, key): raise KeyError(key) return node.content except KeyError: - raise KeyError(key) + raise from KeyError(key) def __delitem__(self, key): """Delete the value associated with some topic filter :key""" @@ -67,7 +67,7 @@ def __delitem__(self, key): lst.append((parent, k, node)) node.content = None except KeyError: - raise KeyError(key) + raise from KeyError(key) else: # cleanup for parent, k, node in reversed(lst): if node.children or node.content is not None: From b152dca34d04c624b1f76bd5b015747868349adf Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Tue, 25 Aug 2020 02:32:18 +0000 Subject: [PATCH 3/6] Fix Pylint errors --- adafruit_minimqtt/adafruit_minimqtt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index bd5d3eb..01717d7 100755 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -246,7 +246,7 @@ def remove_topic_callback(self, mqtt_topic): try: del self._on_message_filtered[mqtt_topic] except KeyError: - raise KeyError("MQTT topic callback not added with add_topic_callback.") + raise from KeyError("MQTT topic callback not added with add_topic_callback.") @property def on_message(self): @@ -287,7 +287,7 @@ def connect(self, clean_session=True): conntype = _the_interface.TLS_MODE self._sock.connect((self.broker, self.port), conntype) except RuntimeError as e: - raise MMQTTException("Invalid broker address defined.", e) + raise from MMQTTException("Invalid broker address defined.", e) else: try: if self.logger is not None: @@ -299,7 +299,7 @@ def connect(self, clean_session=True): )[0] self._sock.connect(addr[-1], _the_interface.TCP_MODE) except RuntimeError as e: - raise MMQTTException("Invalid broker address defined.", e) + raise from MMQTTException("Invalid broker address defined.", e) # Fixed Header fixed_header = bytearray([0x10]) From 1facbec0833395780b59c66fc5380d49e7710b64 Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Tue, 25 Aug 2020 02:44:28 +0000 Subject: [PATCH 4/6] Fix Pylint Error Since this is an explicit error, I don't think there is any additional context https://docs.python.org/3/library/exceptions.html --- adafruit_minimqtt/matcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_minimqtt/matcher.py b/adafruit_minimqtt/matcher.py index c91c1ad..0b56faa 100755 --- a/adafruit_minimqtt/matcher.py +++ b/adafruit_minimqtt/matcher.py @@ -55,7 +55,7 @@ def __getitem__(self, key): raise KeyError(key) return node.content except KeyError: - raise from KeyError(key) + raise KeyError(key) from None def __delitem__(self, key): """Delete the value associated with some topic filter :key""" @@ -67,7 +67,7 @@ def __delitem__(self, key): lst.append((parent, k, node)) node.content = None except KeyError: - raise from KeyError(key) + raise KeyError(key) from None else: # cleanup for parent, k, node in reversed(lst): if node.children or node.content is not None: From ddb0b21d46edfe98aa4f7ffd117b0a4565f02d96 Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Tue, 25 Aug 2020 02:46:37 +0000 Subject: [PATCH 5/6] Fix Pylint Error Since this is an explicit error, I don't think there is any additional context https://docs.python.org/3/library/exceptions.html --- adafruit_minimqtt/adafruit_minimqtt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index 01717d7..4c43440 100755 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -246,7 +246,7 @@ def remove_topic_callback(self, mqtt_topic): try: del self._on_message_filtered[mqtt_topic] except KeyError: - raise from KeyError("MQTT topic callback not added with add_topic_callback.") + raise KeyError("MQTT topic callback not added with add_topic_callback.") from None @property def on_message(self): @@ -287,7 +287,7 @@ def connect(self, clean_session=True): conntype = _the_interface.TLS_MODE self._sock.connect((self.broker, self.port), conntype) except RuntimeError as e: - raise from MMQTTException("Invalid broker address defined.", e) + raise MMQTTException("Invalid broker address defined.", e) from None else: try: if self.logger is not None: @@ -299,7 +299,7 @@ def connect(self, clean_session=True): )[0] self._sock.connect(addr[-1], _the_interface.TCP_MODE) except RuntimeError as e: - raise from MMQTTException("Invalid broker address defined.", e) + raise MMQTTException("Invalid broker address defined.", e) from None # Fixed Header fixed_header = bytearray([0x10]) From 8b89923c7b3a33bf9eaf2e7d229b4ca871e5ee99 Mon Sep 17 00:00:00 2001 From: askpatricw <4002194+askpatrickw@users.noreply.github.com> Date: Tue, 25 Aug 2020 10:07:48 -0700 Subject: [PATCH 6/6] Ran black on file --- adafruit_minimqtt/adafruit_minimqtt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index 4c43440..6bfc60e 100755 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -246,7 +246,9 @@ def remove_topic_callback(self, mqtt_topic): try: del self._on_message_filtered[mqtt_topic] except KeyError: - raise KeyError("MQTT topic callback not added with add_topic_callback.") from None + raise KeyError( + "MQTT topic callback not added with add_topic_callback." + ) from None @property def on_message(self):