Skip to content

Commit d11e18e

Browse files
authored
Merge pull request adafruit#22 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents fa8396f + 9bd9e87 commit d11e18e

9 files changed

+341
-249
lines changed

.github/workflows/build.yml

+1-1
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 --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_minimqtt.py

+142-94
Large diffs are not rendered by default.

docs/conf.py

+65-47
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
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
@@ -22,29 +23,32 @@
2223
autodoc_mock_imports = ["micropython", "microcontroller", "random", "adafruit_logging"]
2324

2425

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

2731
# Add any paths that contain templates here, relative to this directory.
28-
templates_path = ['_templates']
32+
templates_path = ["_templates"]
2933

30-
source_suffix = '.rst'
34+
source_suffix = ".rst"
3135

3236
# The master toctree document.
33-
master_doc = 'index'
37+
master_doc = "index"
3438

3539
# General information about the project.
36-
project = u'Adafruit MiniMQTT Library'
37-
copyright = u'2019 Brent Rubell'
38-
author = u'Brent Rubell'
40+
project = u"Adafruit MiniMQTT Library"
41+
copyright = u"2019 Brent Rubell"
42+
author = u"Brent Rubell"
3943

4044
# The version info for the project you're documenting, acts as replacement for
4145
# |version| and |release|, also used in various other places throughout the
4246
# built documents.
4347
#
4448
# The short X.Y version.
45-
version = u'1.0'
49+
version = u"1.0"
4650
# The full version, including alpha/beta/rc tags.
47-
release = u'1.0'
51+
release = u"1.0"
4852

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

6165
# The reST default role (used for this markup: `text`) to use for all
6266
# documents.
@@ -68,7 +72,7 @@
6872
add_function_parentheses = True
6973

7074
# The name of the Pygments (syntax highlighting) style to use.
71-
pygments_style = 'sphinx'
75+
pygments_style = "sphinx"
7276

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

8892
if not on_rtd: # only import and set the theme if we're building docs locally
8993
try:
9094
import sphinx_rtd_theme
91-
html_theme = 'sphinx_rtd_theme'
92-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
95+
96+
html_theme = "sphinx_rtd_theme"
97+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9398
except:
94-
html_theme = 'default'
95-
html_theme_path = ['.']
99+
html_theme = "default"
100+
html_theme_path = ["."]
96101
else:
97-
html_theme_path = ['.']
102+
html_theme_path = ["."]
98103

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

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

110115
# Output file base name for HTML help builder.
111-
htmlhelp_basename = 'AdafruitMinimqttLibrarydoc'
116+
htmlhelp_basename = "AdafruitMinimqttLibrarydoc"
112117

113118
# -- Options for LaTeX output ---------------------------------------------
114119

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

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

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

143150
# One entry per manual page. List of tuples
144151
# (source start file, name, description, authors, manual section).
145152
man_pages = [
146-
(master_doc, 'AdafruitMiniMQTTlibrary', u'Adafruit MiniMQTT Library Documentation',
147-
[author], 1)
153+
(
154+
master_doc,
155+
"AdafruitMiniMQTTlibrary",
156+
u"Adafruit MiniMQTT Library Documentation",
157+
[author],
158+
1,
159+
)
148160
]
149161

150162
# -- Options for Texinfo output -------------------------------------------
@@ -153,7 +165,13 @@
153165
# (source start file, target name, title, author,
154166
# dir menu entry, description, category)
155167
texinfo_documents = [
156-
(master_doc, 'AdafruitMiniMQTTLibrary', u'Adafruit MiniMQTT Library Documentation',
157-
author, 'AdafruitMiniMQTTLibrary', 'One line description of project.',
158-
'Miscellaneous'),
168+
(
169+
master_doc,
170+
"AdafruitMiniMQTTLibrary",
171+
u"Adafruit MiniMQTT Library Documentation",
172+
author,
173+
"AdafruitMiniMQTTLibrary",
174+
"One line description of project.",
175+
"Miscellaneous",
176+
),
159177
]

examples/minimqtt_adafruitio_wifi.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
3535
"""Use below for Most Boards"""
3636
status_light = neopixel.NeoPixel(
37-
board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
37+
board.NEOPIXEL, 1, brightness=0.2
38+
) # Uncomment for Most Boards
3839
"""Uncomment below for ItsyBitsy M4"""
3940
# status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
4041
# Uncomment below for an externally defined RGB LED
@@ -44,16 +45,15 @@
4445
# GREEN_LED = PWMOut.PWMOut(esp, 27)
4546
# BLUE_LED = PWMOut.PWMOut(esp, 25)
4647
# status_light = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED)
47-
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(
48-
esp, secrets, status_light)
48+
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)
4949

5050
### Feeds ###
5151

5252
# Setup a feed named 'photocell' for publishing to a feed
53-
photocell_feed = secrets['aio_username'] + '/feeds/photocell'
53+
photocell_feed = secrets["aio_username"] + "/feeds/photocell"
5454

5555
# Setup a feed named 'onoff' for subscribing to changes
56-
onoff_feed = secrets['aio_username'] + '/feeds/onoff'
56+
onoff_feed = secrets["aio_username"] + "/feeds/onoff"
5757

5858
### Code ###
5959

@@ -62,39 +62,41 @@
6262
def connected(client, userdata, flags, rc):
6363
# This function will be called when the client is connected
6464
# successfully to the broker.
65-
print('Connected to Adafruit IO! Listening for topic changes on %s' % onoff_feed)
65+
print("Connected to Adafruit IO! Listening for topic changes on %s" % onoff_feed)
6666
# Subscribe to all changes on the onoff_feed.
6767
client.subscribe(onoff_feed)
6868

6969

7070
def disconnected(client, userdata, rc):
7171
# This method is called when the client is disconnected
72-
print('Disconnected from Adafruit IO!')
72+
print("Disconnected from Adafruit IO!")
7373

7474

7575
def message(client, topic, message):
7676
# This method is called when a topic the client is subscribed to
7777
# has a new message.
78-
print('New message on topic {0}: {1}'.format(topic, message))
78+
print("New message on topic {0}: {1}".format(topic, message))
7979

8080

8181
# Connect to WiFi
8282
wifi.connect()
8383

8484
# Set up a MiniMQTT Client
85-
mqtt_client = MQTT(socket,
86-
broker='io.adafruit.com',
87-
username=secrets['aio_username'],
88-
password=secrets['aio_key'],
89-
network_manager=wifi)
85+
mqtt_client = MQTT(
86+
socket,
87+
broker="io.adafruit.com",
88+
username=secrets["aio_username"],
89+
password=secrets["aio_key"],
90+
network_manager=wifi,
91+
)
9092

9193
# Setup the callback methods above
9294
mqtt_client.on_connect = connected
9395
mqtt_client.on_disconnect = disconnected
9496
mqtt_client.on_message = message
9597

9698
# Connect the client to the MQTT broker.
97-
print('Connecting to Adafruit IO...')
99+
print("Connecting to Adafruit IO...")
98100
mqtt_client.connect()
99101

100102
photocell_val = 0
@@ -103,8 +105,8 @@ def message(client, topic, message):
103105
mqtt_client.loop()
104106

105107
# Send a new message
106-
print('Sending photocell value: %d...' % photocell_val)
108+
print("Sending photocell value: %d..." % photocell_val)
107109
mqtt_client.publish(photocell_feed, photocell_val)
108-
print('Sent!')
110+
print("Sent!")
109111
photocell_val += 1
110112
time.sleep(1)

0 commit comments

Comments
 (0)