Skip to content

fixed imports for adafruit_minimqtt #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adafruit_azureiot/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
def _bytes_from_decode_data(data: str):
try:
return data.encode("ascii")
except:
raise ValueError("string argument should contain only ASCII characters")
except Exception as exc:
raise ValueError("string argument should contain only ASCII characters") from exc


def b64encode(toencode: bytes) -> bytes:
Expand Down
6 changes: 3 additions & 3 deletions adafruit_azureiot/device_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DeviceRegistrationError(Exception):
"""

def __init__(self, message):
super(DeviceRegistrationError, self).__init__(message)
super().__init__(message)
self.message = message


Expand Down Expand Up @@ -104,7 +104,7 @@ def _loop_assign(self, operation_id, headers) -> str:
except ValueError as error:
err = "ERROR: " + str(error) + " => " + str(response)
self._logger.error(err)
raise DeviceRegistrationError(err)
raise DeviceRegistrationError(err) from error

loop_try = 0

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

if "errorCode" in data:
err = "DPS => " + str(data)
Expand Down
2 changes: 1 addition & 1 deletion adafruit_azureiot/iot_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def __init__(self, message: str):
"""Create the IoT Error
:param str message: The error message
"""
super(IoTError, self).__init__(message)
super().__init__(message)
self.message = message
4 changes: 2 additions & 2 deletions adafruit_azureiot/iot_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import gc
import json
import time
import adafruit_minimqtt as minimqtt
from adafruit_minimqtt import MQTT
import adafruit_minimqtt.adafruit_minimqtt as minimqtt
from adafruit_minimqtt.adafruit_minimqtt import MQTT
import adafruit_logging as logging
from .iot_error import IoTError
from .keys import compute_derived_symmetric_key
Expand Down
4 changes: 2 additions & 2 deletions adafruit_azureiot/iothub_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def __init__(self, socket, iface, device_connection_string: str, token_expires:
try:
cs_args = device_connection_string.split(DELIMITER)
connection_string_values = dict(arg.split(VALUE_SEPARATOR, 1) for arg in cs_args)
except (ValueError, AttributeError):
raise ValueError("Connection string is required and should not be empty or blank and must be supplied as a string")
except (ValueError, AttributeError) as e:
raise ValueError("Connection string is required and should not be empty or blank and must be supplied as a string") from e

if len(cs_args) != len(connection_string_values):
raise ValueError("Invalid Connection String - Unable to parse")
Expand Down
2 changes: 1 addition & 1 deletion adafruit_azureiot/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Quoter(defaultdict):
# of cached keys don't call Python code at all).
def __init__(self, safe):
"""safe: bytes object."""
super(Quoter, self).__init__()
super().__init__()
self.safe = _ALWAYS_SAFE.union(safe)

def __missing__(self, b):
Expand Down