Skip to content

Commit 91a7259

Browse files
authored
Merge pull request #23 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 471f556 + f5ac16a commit 91a7259

File tree

7 files changed

+115
-91
lines changed

7 files changed

+115
-91
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_trellism4.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
class _NeoPixelArray:
5555
"""Creates a NeoPixel array for use in the ``TrellisM4Express`` class."""
56+
5657
def __init__(self, pin, *, width, height, rotation=0):
5758
self._neopixel = neopixel.NeoPixel(pin, width * height, auto_write=True)
5859
if rotation % 90 != 0:
@@ -243,11 +244,14 @@ class TrellisM4Express:
243244
time.sleep(0.08)
244245
current_press = pressed
245246
"""
247+
246248
def __init__(self, rotation=0):
247249
self._rotation = rotation
248250

249251
# Define NeoPixels
250-
self.pixels = _NeoPixelArray(board.NEOPIXEL, width=8, height=4, rotation=rotation)
252+
self.pixels = _NeoPixelArray(
253+
board.NEOPIXEL, width=8, height=4, rotation=rotation
254+
)
251255
"""Sequence like object representing the 32 NeoPixels on the Trellis M4 Express, Provides a
252256
two dimensional representation of the NeoPixel grid.
253257

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
# TODO: Please Read!
@@ -23,29 +24,32 @@
2324
# autodoc_mock_imports = ["neopixel"]
2425

2526

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

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

31-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3236

3337
# The master toctree document.
34-
master_doc = 'index'
38+
master_doc = "index"
3539

3640
# General information about the project.
37-
project = u'Adafruit TrellisM4 Library'
38-
copyright = u'2018 Scott Shawcroft'
39-
author = u'Scott Shawcroft'
41+
project = u"Adafruit TrellisM4 Library"
42+
copyright = u"2018 Scott Shawcroft"
43+
author = u"Scott Shawcroft"
4044

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

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

6266
# The reST default role (used for this markup: `text`) to use for all
6367
# documents.
@@ -69,7 +73,7 @@
6973
add_function_parentheses = True
7074

7175
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7377

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

8993
if not on_rtd: # only import and set the theme if we're building docs locally
9094
try:
9195
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
96+
97+
html_theme = "sphinx_rtd_theme"
98+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9499
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
97102
else:
98-
html_theme_path = ['.']
103+
html_theme_path = ["."]
99104

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

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

111116
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitTrellism4Librarydoc'
117+
htmlhelp_basename = "AdafruitTrellism4Librarydoc"
113118

114119
# -- Options for LaTeX output ---------------------------------------------
115120

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

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

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

144151
# One entry per manual page. List of tuples
145152
# (source start file, name, description, authors, manual section).
146153
man_pages = [
147-
(master_doc, 'AdafruitTrellisM4library', u'Adafruit TrellisM4 Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitTrellisM4library",
157+
u"Adafruit TrellisM4 Library Documentation",
158+
[author],
159+
1,
160+
)
149161
]
150162

151163
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +166,13 @@
154166
# (source start file, target name, title, author,
155167
# dir menu entry, description, category)
156168
texinfo_documents = [
157-
(master_doc, 'AdafruitTrellisM4Library', u'Adafruit TrellisM4 Library Documentation',
158-
author, 'AdafruitTrellisM4Library', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitTrellisM4Library",
172+
u"Adafruit TrellisM4 Library Documentation",
173+
author,
174+
"AdafruitTrellisM4Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/trellism4_neopixel_simpletest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def wheel(pos):
2020

2121
for x in range(trellis.pixels.width):
2222
for y in range(trellis.pixels.height):
23-
pixel_index = (((y * 8) + x) * 256 // 32)
23+
pixel_index = ((y * 8) + x) * 256 // 32
2424
trellis.pixels[x, y] = wheel(pixel_index & 255)
2525

2626

@@ -31,14 +31,14 @@ def wheel(pos):
3131
if press:
3232
print("Pressed:", press)
3333
pixel = (press[1] * 8) + press[0]
34-
pixel_index = (pixel * 256 // 32)
34+
pixel_index = pixel * 256 // 32
3535
trellis.pixels.fill(wheel(pixel_index & 255))
3636
for release in current_press - pressed:
3737
if release:
3838
print("Released:", release)
3939
for x in range(trellis.pixels.width):
4040
for y in range(trellis.pixels.height):
41-
pixel_index = (((y * 8) + x) * 256 // 32)
41+
pixel_index = ((y * 8) + x) * 256 // 32
4242
trellis.pixels[x, y] = wheel(pixel_index & 255)
4343
time.sleep(0.08)
4444
current_press = pressed

examples/trellism4_neopixel_toggle.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def wheel(pos):
3434

3535
if not led_on[x][y]:
3636
print("Turning on:", press)
37-
pixel_index = ((x + (y * 8)) * 256 // 32)
37+
pixel_index = (x + (y * 8)) * 256 // 32
3838
trellis.pixels[x, y] = wheel(pixel_index & 255)
3939
led_on[x][y] = True
4040

examples/trellism4_wavefile_synth/trellism4_wavefile_synth.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@
1414
# low brightness on the neopixles
1515
trellis.pixels.brightness = 0.05
1616
# each musical note letter
17-
note_letters = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
17+
note_letters = ["C", "D", "E", "F", "G", "A", "B"]
1818
# colors of the rainbow
1919
colors = [
20-
(255, 0, 0), (255, 127, 0), (255, 255, 0),
21-
(0, 255, 0), (0, 0, 255), (56, 43, 105), (139, 0, 255)]
20+
(255, 0, 0),
21+
(255, 127, 0),
22+
(255, 255, 0),
23+
(0, 255, 0),
24+
(0, 0, 255),
25+
(56, 43, 105),
26+
(139, 0, 255),
27+
]
2228

2329
# dictionary holding note string to wave file value.
2430
# e.g. {... "sined4": audioio.WaveFile(open("notes/sine/d4.wav")), ...}
@@ -39,15 +45,19 @@
3945
# add wave file to dictionary
4046
key = "{}{}".format(wave_type, cur_note)
4147
notes[key] = WaveFile(
42-
open("notes/{}/{}.wav".format(wave_type, cur_note), "rb"))
48+
open("notes/{}/{}.wav".format(wave_type, cur_note), "rb")
49+
)
4350

4451
# main audio object
4552
audio = AudioOut(left_channel=board.A0, right_channel=board.A1)
4653
# mixer to allow pylyphonic playback
4754
mixer = Mixer(
48-
voice_count=8, sample_rate=8000,
49-
channel_count=2, bits_per_sample=16,
50-
samples_signed=True)
55+
voice_count=8,
56+
sample_rate=8000,
57+
channel_count=2,
58+
bits_per_sample=16,
59+
samples_signed=True,
60+
)
5161

5262
audio.play(mixer)
5363

@@ -79,7 +89,7 @@
7989
# if we aren't already playing this note and we have available voice
8090
if key not in used_voices.keys() and available_voices:
8191
# build not string
82-
note_for_key = "{}{}".format(note_letters[key[0]], key[1]+3)
92+
note_for_key = "{}{}".format(note_letters[key[0]], key[1] + 3)
8393
note_to_play = "{}{}".format(current_wave_type, note_for_key)
8494
# if the note exists in the notes dictionary
8595
if note_to_play in notes:

0 commit comments

Comments
 (0)