Skip to content

Commit d6acff9

Browse files
authored
Merge pull request #7 from adafruit/pylint-update
Pylint update
2 parents 0c71d36 + 49d5ee4 commit d6acff9

File tree

5 files changed

+116
-96
lines changed

5 files changed

+116
-96
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_gc_iot_core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545
__version__ = "0.0.0-auto.0"
4646
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_GC_IOT_Core.git"
4747

48+
4849
class MQTT_API_ERROR(Exception):
4950
"""Exception raised on MQTT API return-code errors."""
51+
5052
# pylint: disable=unnecessary-pass
5153
pass
5254

55+
5356
class MQTT_API:
5457
"""Client for interacting with Google's Cloud Core MQTT API.
5558
@@ -343,7 +346,6 @@ def client_id(self):
343346
self.logger.debug("Client ID: {}".format(client_id))
344347
return client_id
345348

346-
347349
def generate_jwt(self, ttl=43200, algo="RS256"):
348350
"""Generates a JSON Web Token (https://jwt.io/) using network time.
349351
:param int jwt_ttl: When the JWT token expires, defaults to 43200 minutes (or 12 hours).

docs/conf.py

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,52 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# Uncomment the below if you use native CircuitPython modules such as
2021
# digitalio, micropython and busio. List the modules you use. Without it, the
2122
# autodoc module docs will fail to generate with a warning.
2223
autodoc_mock_imports = ["adafruit_logging", "adafruit_jwt", "adafruit_ntp", "rtc"]
2324

24-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
25+
intersphinx_mapping = {
26+
"python": ("https://docs.python.org/3.4", None),
27+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
28+
}
2529

2630
# Add any paths that contain templates here, relative to this directory.
27-
templates_path = ['_templates']
31+
templates_path = ["_templates"]
2832

29-
source_suffix = '.rst'
33+
source_suffix = ".rst"
3034

3135
# The master toctree document.
32-
master_doc = 'index'
36+
master_doc = "index"
3337

3438
# General information about the project.
35-
project = u'Adafruit GC_IOT_CORE Library'
36-
copyright = u'2019 Brent Rubell'
37-
author = u'Brent Rubell'
39+
project = "Adafruit GC_IOT_CORE Library"
40+
copyright = "2019 Brent Rubell"
41+
author = "Brent Rubell"
3842

3943
# The version info for the project you're documenting, acts as replacement for
4044
# |version| and |release|, also used in various other places throughout the
4145
# built documents.
4246
#
4347
# The short X.Y version.
44-
version = u'1.0'
48+
version = "1.0"
4549
# The full version, including alpha/beta/rc tags.
46-
release = u'1.0'
50+
release = "1.0"
4751

4852
# The language for content autogenerated by Sphinx. Refer to documentation
4953
# for a list of supported languages.
@@ -55,7 +59,7 @@
5559
# List of patterns, relative to source directory, that match files and
5660
# directories to ignore when looking for source files.
5761
# This patterns also effect to html_static_path and html_extra_path
58-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
62+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5963

6064
# The reST default role (used for this markup: `text`) to use for all
6165
# documents.
@@ -67,7 +71,7 @@
6771
add_function_parentheses = True
6872

6973
# The name of the Pygments (syntax highlighting) style to use.
70-
pygments_style = 'sphinx'
74+
pygments_style = "sphinx"
7175

7276
# If true, `todo` and `todoList` produce output, else they produce nothing.
7377
todo_include_todos = False
@@ -82,68 +86,76 @@
8286
# The theme to use for HTML and HTML Help pages. See the documentation for
8387
# a list of builtin themes.
8488
#
85-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
89+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8690

8791
if not on_rtd: # only import and set the theme if we're building docs locally
8892
try:
8993
import sphinx_rtd_theme
90-
html_theme = 'sphinx_rtd_theme'
91-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
94+
95+
html_theme = "sphinx_rtd_theme"
96+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9297
except:
93-
html_theme = 'default'
94-
html_theme_path = ['.']
98+
html_theme = "default"
99+
html_theme_path = ["."]
95100
else:
96-
html_theme_path = ['.']
101+
html_theme_path = ["."]
97102

98103
# Add any paths that contain custom static files (such as style sheets) here,
99104
# relative to this directory. They are copied after the builtin static files,
100105
# so a file named "default.css" will overwrite the builtin "default.css".
101-
html_static_path = ['_static']
106+
html_static_path = ["_static"]
102107

103108
# The name of an image file (relative to this directory) to use as a favicon of
104109
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
105110
# pixels large.
106111
#
107-
html_favicon = '_static/favicon.ico'
112+
html_favicon = "_static/favicon.ico"
108113

109114
# Output file base name for HTML help builder.
110-
htmlhelp_basename = 'AdafruitGc_iot_coreLibrarydoc'
115+
htmlhelp_basename = "AdafruitGc_iot_coreLibrarydoc"
111116

112117
# -- Options for LaTeX output ---------------------------------------------
113118

114119
latex_elements = {
115-
# The paper size ('letterpaper' or 'a4paper').
116-
#
117-
# 'papersize': 'letterpaper',
118-
119-
# The font size ('10pt', '11pt' or '12pt').
120-
#
121-
# 'pointsize': '10pt',
122-
123-
# Additional stuff for the LaTeX preamble.
124-
#
125-
# 'preamble': '',
126-
127-
# Latex figure (float) alignment
128-
#
129-
# 'figure_align': 'htbp',
120+
# The paper size ('letterpaper' or 'a4paper').
121+
#
122+
# 'papersize': 'letterpaper',
123+
# The font size ('10pt', '11pt' or '12pt').
124+
#
125+
# 'pointsize': '10pt',
126+
# Additional stuff for the LaTeX preamble.
127+
#
128+
# 'preamble': '',
129+
# Latex figure (float) alignment
130+
#
131+
# 'figure_align': 'htbp',
130132
}
131133

132134
# Grouping the document tree into LaTeX files. List of tuples
133135
# (source start file, target name, title,
134136
# author, documentclass [howto, manual, or own class]).
135137
latex_documents = [
136-
(master_doc, 'AdafruitGC_IOT_CORELibrary.tex', u'AdafruitGC_IOT_CORE Library Documentation',
137-
author, 'manual'),
138+
(
139+
master_doc,
140+
"AdafruitGC_IOT_CORELibrary.tex",
141+
"AdafruitGC_IOT_CORE Library Documentation",
142+
author,
143+
"manual",
144+
),
138145
]
139146

140147
# -- Options for manual page output ---------------------------------------
141148

142149
# One entry per manual page. List of tuples
143150
# (source start file, name, description, authors, manual section).
144151
man_pages = [
145-
(master_doc, 'AdafruitGC_IOT_CORElibrary', u'Adafruit GC_IOT_CORE Library Documentation',
146-
[author], 1)
152+
(
153+
master_doc,
154+
"AdafruitGC_IOT_CORElibrary",
155+
"Adafruit GC_IOT_CORE Library Documentation",
156+
[author],
157+
1,
158+
)
147159
]
148160

149161
# -- Options for Texinfo output -------------------------------------------
@@ -152,7 +164,13 @@
152164
# (source start file, target name, title, author,
153165
# dir menu entry, description, category)
154166
texinfo_documents = [
155-
(master_doc, 'AdafruitGC_IOT_CORELibrary', u'Adafruit GC_IOT_CORE Library Documentation',
156-
author, 'AdafruitGC_IOT_CORELibrary', 'One line description of project.',
157-
'Miscellaneous'),
167+
(
168+
master_doc,
169+
"AdafruitGC_IOT_CORELibrary",
170+
"Adafruit GC_IOT_CORE Library Documentation",
171+
author,
172+
"AdafruitGC_IOT_CORELibrary",
173+
"One line description of project.",
174+
"Miscellaneous",
175+
),
158176
]

examples/gc_iot_core_simpletest.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
3232
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
3333
"""Use below for Most Boards"""
34-
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
34+
status_light = neopixel.NeoPixel(
35+
board.NEOPIXEL, 1, brightness=0.2
36+
) # Uncomment for Most Boards
3537
"""Uncomment below for ItsyBitsy M4"""
3638
# status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
3739
# Uncomment below for an externally defined RGB LED
@@ -50,35 +52,41 @@
5052
def connect(client, userdata, flags, rc):
5153
# This function will be called when the client is connected
5254
# successfully to the broker.
53-
print('Connected to MQTT Broker!')
54-
print('Flags: {0}\n RC: {1}'.format(flags, rc))
55+
print("Connected to MQTT Broker!")
56+
print("Flags: {0}\n RC: {1}".format(flags, rc))
5557
# Subscribes to commands/# topic
5658
google_mqtt.subscribe_to_all_commands()
5759

5860
# Publish to the default "events" topic
59-
google_mqtt.publish('testing','events', qos=1)
61+
google_mqtt.publish("testing", "events", qos=1)
62+
6063

6164
def disconnect(client, userdata, rc):
6265
# This method is called when the client disconnects
6366
# from the broker.
64-
print('Disconnected from MQTT Broker!')
67+
print("Disconnected from MQTT Broker!")
68+
6569

6670
def subscribe(client, userdata, topic, granted_qos):
6771
# This method is called when the client subscribes to a new topic.
68-
print('Subscribed to {0} with QOS level {1}'.format(topic, granted_qos))
72+
print("Subscribed to {0} with QOS level {1}".format(topic, granted_qos))
73+
6974

7075
def unsubscribe(client, userdata, topic, pid):
7176
# This method is called when the client unsubscribes from a topic.
72-
print('Unsubscribed from {0} with PID {1}'.format(topic, pid))
77+
print("Unsubscribed from {0} with PID {1}".format(topic, pid))
78+
7379

7480
def publish(client, userdata, topic, pid):
7581
# This method is called when the client publishes data to a topic.
76-
print('Published to {0} with PID {1}'.format(topic, pid))
82+
print("Published to {0} with PID {1}".format(topic, pid))
83+
7784

7885
def message(client, topic, msg):
7986
# This method is called when the client receives data from a topic.
8087
print("Message from {}: {}".format(topic, msg))
8188

89+
8290
# Connect to WiFi
8391
print("Connecting to WiFi...")
8492
wifi.connect()
@@ -93,12 +101,14 @@ def message(client, topic, msg):
93101
# print("Your JWT is: ", jwt)
94102

95103
# Set up a new MiniMQTT Client
96-
client = MQTT(socket,
97-
broker = google_iot.broker,
98-
username = google_iot.username,
99-
password = secrets['jwt'],
100-
client_id = google_iot.cid,
101-
network_manager = wifi)
104+
client = MQTT(
105+
socket,
106+
broker=google_iot.broker,
107+
username=google_iot.username,
108+
password=secrets["jwt"],
109+
client_id=google_iot.cid,
110+
network_manager=wifi,
111+
)
102112

103113
# Initialize Google MQTT API Client
104114
google_mqtt = MQTT_API(client)
@@ -111,7 +121,7 @@ def message(client, topic, msg):
111121
google_mqtt.on_publish = publish
112122
google_mqtt.on_message = message
113123

114-
print('Attempting to connect to %s'%client.broker)
124+
print("Attempting to connect to %s" % client.broker)
115125
google_mqtt.connect()
116126

117127
# Pump the message loop forever, all events are

0 commit comments

Comments
 (0)