Skip to content

Commit 188e90b

Browse files
author
brentru
committed
linted!
1 parent bf18c6b commit 188e90b

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

adafruit_io/adafruit_io.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* Adafruit CircuitPython firmware for the supported boards:
3636
https://github.com/adafruit/circuitpython/releases
3737
"""
38-
from time import struct_time
38+
import time
3939
from adafruit_io.adafruit_io_errors import (
4040
AdafruitIO_RequestError,
4141
AdafruitIO_ThrottleError,
@@ -95,8 +95,8 @@ def connect(self):
9595
"""
9696
try:
9797
self._client.connect()
98-
except error as e:
99-
AdafruitIO_MQTTError(e)
98+
except:
99+
raise AdafruitIO_MQTTError("Unable to connect to Adafruit IO.")
100100

101101
def disconnect(self):
102102
"""Disconnects from Adafruit IO.
@@ -109,7 +109,7 @@ def is_connected(self):
109109
"""Returns if connected to Adafruit IO MQTT Broker."""
110110
return self._client.is_connected
111111

112-
# pylint: disable=not-callable
112+
# pylint: disable=not-callable, unused-argument
113113
def _on_connect_mqtt(self, client, userdata, flags, return_code):
114114
"""Runs when the on_connect callback is run from code.
115115
"""
@@ -123,7 +123,7 @@ def _on_connect_mqtt(self, client, userdata, flags, return_code):
123123
if self.on_connect is not None:
124124
self.on_connect(self)
125125

126-
# pylint: disable=not-callable
126+
# pylint: disable=not-callable, unused-argument
127127
def _on_disconnect_mqtt(self, client, userdata, return_code):
128128
"""Runs when the on_disconnect callback is run from
129129
code.
@@ -307,18 +307,19 @@ def publish_multiple(self, feeds_and_data, timeout=3, is_group=False):
307307
"""
308308
if isinstance(feeds_and_data, list):
309309
feed_data = []
310-
for t, d in feeds_and_data:
311-
feed_data.append((t, d))
310+
for topic, data in feeds_and_data:
311+
feed_data.append((topic, data))
312312
else:
313313
raise AdafruitIO_MQTTError("This method accepts a list of tuples.")
314-
for t, d in feed_data:
314+
for topic, data in feed_data:
315315
if is_group:
316-
self.publish(t, d, is_group=True)
316+
self.publish(topic, data, is_group=True)
317317
else:
318-
self.publish(t, d)
318+
self.publish(topic, data)
319319
time.sleep(timeout)
320320

321-
def publish(self, feed_key, data, metadata = None, shared_user=None, is_group=False):
321+
# pylint: disable=too-many-arguments
322+
def publish(self, feed_key, data, metadata=None, shared_user=None, is_group=False):
322323
"""Publishes to an An Adafruit IO Feed.
323324
:param str feed_key: Adafruit IO Feed key.
324325
:param str data: Data to publish to the feed or group.
@@ -343,7 +344,7 @@ def publish(self, feed_key, data, metadata = None, shared_user=None, is_group=Fa
343344
..code-block:: python
344345
345346
client.publish('temperature, 'thirty degrees')
346-
347+
347348
Example of publishing an integer to Adafruit IO on group 'weatherstation'.
348349
..code-block:: python
349350
@@ -353,7 +354,7 @@ def publish(self, feed_key, data, metadata = None, shared_user=None, is_group=Fa
353354
..code-block:: python
354355
355356
client.publish('temperature', shared_user='myfriend')
356-
357+
357358
Example of publishing a value along with locational metadata to a feed.
358359
..code-block:: python
359360
@@ -371,11 +372,12 @@ def publish(self, feed_key, data, metadata = None, shared_user=None, is_group=Fa
371372
if isinstance(data, int or float):
372373
data = str(data)
373374
csv_string = data + "," + metadata
374-
self._client.publish("{0}/feeds/{1}/csv".format(self._user, feed_key), csv_string)
375+
self._client.publish(
376+
"{0}/feeds/{1}/csv".format(self._user, feed_key), csv_string
377+
)
375378
else:
376379
self._client.publish("{0}/feeds/{1}".format(self._user, feed_key), data)
377380

378-
379381
def get(self, feed_key):
380382
"""Calling this method will make Adafruit IO publish the most recent
381383
value on feed_key.
@@ -611,17 +613,17 @@ def receive_time(self):
611613
https://circuitpython.readthedocs.io/en/latest/shared-bindings/time/__init__.html#time.struct_time
612614
"""
613615
path = self._compose_path("integrations/time/struct.json")
614-
time = self._get(path)
615-
return struct_time(
616+
time_struct = self._get(path)
617+
return time.struct_time(
616618
(
617-
time["year"],
618-
time["mon"],
619-
time["mday"],
620-
time["hour"],
621-
time["min"],
622-
time["sec"],
623-
time["wday"],
624-
time["yday"],
625-
time["isdst"],
619+
time_struct["year"],
620+
time_struct["mon"],
621+
time_struct["mday"],
622+
time_struct["hour"],
623+
time_struct["min"],
624+
time_struct["sec"],
625+
time_struct["wday"],
626+
time_struct["yday"],
627+
time_struct["isdst"],
626628
)
627629
)

0 commit comments

Comments
 (0)