Skip to content

Commit 2a5af6a

Browse files
authored
Merge pull request #23 from codingbandit/master
fixed imports for adafruit_minimqtt
2 parents 2a83561 + d7c9140 commit 2a5af6a

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

adafruit_azureiot/base64.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
def _bytes_from_decode_data(data: str):
4747
try:
4848
return data.encode("ascii")
49-
except:
50-
raise ValueError("string argument should contain only ASCII characters")
49+
except Exception as exc:
50+
raise ValueError("string argument should contain only ASCII characters") from exc
5151

5252

5353
def b64encode(toencode: bytes) -> bytes:

adafruit_azureiot/device_registration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DeviceRegistrationError(Exception):
4949
"""
5050

5151
def __init__(self, message):
52-
super(DeviceRegistrationError, self).__init__(message)
52+
super().__init__(message)
5353
self.message = message
5454

5555

@@ -104,7 +104,7 @@ def _loop_assign(self, operation_id, headers) -> str:
104104
except ValueError as error:
105105
err = "ERROR: " + str(error) + " => " + str(response)
106106
self._logger.error(err)
107-
raise DeviceRegistrationError(err)
107+
raise DeviceRegistrationError(err) from error
108108

109109
loop_try = 0
110110

@@ -225,7 +225,7 @@ def register_device(self, expiry: int) -> str:
225225
except ValueError as error:
226226
err = "ERROR: non JSON is received from " + constants.DPS_END_POINT + " => " + str(response) + " .. message : " + str(error)
227227
self._logger.error(err)
228-
raise DeviceRegistrationError(err)
228+
raise DeviceRegistrationError(err) from error
229229

230230
if "errorCode" in data:
231231
err = "DPS => " + str(data)

adafruit_azureiot/iot_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ def __init__(self, message: str):
3838
"""Create the IoT Error
3939
:param str message: The error message
4040
"""
41-
super(IoTError, self).__init__(message)
41+
super().__init__(message)
4242
self.message = message

adafruit_azureiot/iot_mqtt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import gc
3232
import json
3333
import time
34-
import adafruit_minimqtt as minimqtt
35-
from adafruit_minimqtt import MQTT
34+
import adafruit_minimqtt.adafruit_minimqtt as minimqtt
35+
from adafruit_minimqtt.adafruit_minimqtt import MQTT
3636
import adafruit_logging as logging
3737
from .iot_error import IoTError
3838
from .keys import compute_derived_symmetric_key

adafruit_azureiot/iothub_device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def __init__(self, socket, iface, device_connection_string: str, token_expires:
146146
try:
147147
cs_args = device_connection_string.split(DELIMITER)
148148
connection_string_values = dict(arg.split(VALUE_SEPARATOR, 1) for arg in cs_args)
149-
except (ValueError, AttributeError):
150-
raise ValueError("Connection string is required and should not be empty or blank and must be supplied as a string")
149+
except (ValueError, AttributeError) as e:
150+
raise ValueError("Connection string is required and should not be empty or blank and must be supplied as a string") from e
151151

152152
if len(cs_args) != len(connection_string_values):
153153
raise ValueError("Invalid Connection String - Unable to parse")

adafruit_azureiot/quote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Quoter(defaultdict):
128128
# of cached keys don't call Python code at all).
129129
def __init__(self, safe):
130130
"""safe: bytes object."""
131-
super(Quoter, self).__init__()
131+
super().__init__()
132132
self.safe = _ALWAYS_SAFE.union(safe)
133133

134134
def __missing__(self, b):

0 commit comments

Comments
 (0)