Skip to content

Commit a8527a5

Browse files
authored
Merge pull request #24 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 3c1be30 + 2a0e60c commit a8527a5

12 files changed

+200
-143
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 --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_is31fl3731.py

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
_AUDIOSYNC_REGISTER = const(0x06)
6363
_BREATH1_REGISTER = const(0x08)
6464
_BREATH2_REGISTER = const(0x09)
65-
_SHUTDOWN_REGISTER = const(0x0a)
66-
_GAIN_REGISTER = const(0x0b)
67-
_ADC_REGISTER = const(0x0c)
65+
_SHUTDOWN_REGISTER = const(0x0A)
66+
_GAIN_REGISTER = const(0x0B)
67+
_ADC_REGISTER = const(0x0C)
6868

69-
_CONFIG_BANK = const(0x0b)
70-
_BANK_ADDRESS = const(0xfd)
69+
_CONFIG_BANK = const(0x0B)
70+
_BANK_ADDRESS = const(0xFD)
7171

7272
_PICTURE_MODE = const(0x00)
7373
_AUTOPLAY_MODE = const(0x08)
@@ -77,13 +77,15 @@
7777
_BLINK_OFFSET = const(0x12)
7878
_COLOR_OFFSET = const(0x24)
7979

80+
8081
class Matrix:
8182
"""
8283
The Matrix class support the main function for driving the 16x9 matrix Display
8384
8485
:param ~adafruit_bus_device.i2c_device i2c_device: the connected i2c bus i2c_device
8586
:param address: the device address; defaults to 0x74
8687
"""
88+
8789
width = 16
8890
height = 9
8991

@@ -127,7 +129,6 @@ def _bank(self, bank=None):
127129
self._i2c_write_reg(_BANK_ADDRESS, bytearray([bank]))
128130
return None
129131

130-
131132
def _register(self, bank, register, value=None):
132133
self._bank(bank)
133134
if value is None:
@@ -145,7 +146,7 @@ def _init(self):
145146
for frame in range(8):
146147
self.fill(0, False, frame=frame)
147148
for col in range(18):
148-
self._register(frame, _ENABLE_OFFSET + col, 0xff)
149+
self._register(frame, _ENABLE_OFFSET + col, 0xFF)
149150
self.audio_sync(False)
150151

151152
def reset(self):
@@ -184,7 +185,6 @@ def autoplay(self, delay=0, loops=0, frames=0):
184185
self._register(_CONFIG_BANK, _AUTOPLAY2_REGISTER, delay % 64)
185186
self._mode(_AUTOPLAY_MODE | self._frame)
186187

187-
188188
def fade(self, fade_in=None, fade_out=None, pause=0):
189189
"""
190190
Start and stop the fade feature. If both fade_in and fade_out are None (the
@@ -234,8 +234,7 @@ def audio_sync(self, value=None):
234234
"""
235235
return self._register(_CONFIG_BANK, _AUDIOSYNC_REGISTER, value)
236236

237-
def audio_play(self, sample_rate, audio_gain=0,
238-
agc_enable=False, agc_fast=False):
237+
def audio_play(self, sample_rate, audio_gain=0, agc_enable=False, agc_fast=False):
239238
"""Controls the audio play feature
240239
"""
241240
if sample_rate == 0:
@@ -248,8 +247,11 @@ def audio_play(self, sample_rate, audio_gain=0,
248247
audio_gain //= 3
249248
if not 0 <= audio_gain <= 7:
250249
raise ValueError("Audio gain out of range")
251-
self._register(_CONFIG_BANK, _GAIN_REGISTER,
252-
bool(agc_enable) << 3 | bool(agc_fast) << 4 | audio_gain)
250+
self._register(
251+
_CONFIG_BANK,
252+
_GAIN_REGISTER,
253+
bool(agc_enable) << 3 | bool(agc_fast) << 4 | audio_gain,
254+
)
253255
self._mode(_AUDIOPLAY_MODE)
254256

255257
def blink(self, rate=None):
@@ -280,7 +282,7 @@ def fill(self, color=None, blink=None, frame=None):
280282
if color is not None:
281283
if not 0 <= color <= 255:
282284
raise ValueError("Color out of range")
283-
data = bytearray([color] * 25) # Extra byte at front for address.
285+
data = bytearray([color] * 25) # Extra byte at front for address.
284286
while not self.i2c.try_lock():
285287
pass
286288
try:
@@ -290,7 +292,7 @@ def fill(self, color=None, blink=None, frame=None):
290292
finally:
291293
self.i2c.unlock()
292294
if blink is not None:
293-
data = bool(blink) * 0xff
295+
data = bool(blink) * 0xFF
294296
for col in range(18):
295297
self._register(frame, _BLINK_OFFSET + col, data)
296298

@@ -300,7 +302,7 @@ def pixel_addr(x, y):
300302
"""
301303
return x + y * 16
302304

303-
#pylint: disable-msg=too-many-arguments
305+
# pylint: disable-msg=too-many-arguments
304306
def pixel(self, x, y, color=None, blink=None, frame=None):
305307
"""
306308
Blink or brightness for x-, y-pixel
@@ -333,7 +335,8 @@ def pixel(self, x, y, color=None, blink=None, frame=None):
333335
bits &= ~(1 << bit)
334336
self._register(frame, _BLINK_OFFSET + addr, bits)
335337
return None
336-
#pylint: enable-msg=too-many-arguments
338+
339+
# pylint: enable-msg=too-many-arguments
337340

338341
def image(self, img, blink=None, frame=None):
339342
"""Set buffer to value of Python Imaging Library image. The image should
@@ -343,24 +346,28 @@ def image(self, img, blink=None, frame=None):
343346
:param blink: True to blink
344347
:param frame: the frame to set the image
345348
"""
346-
if img.mode != 'L':
347-
raise ValueError('Image must be in mode L.')
349+
if img.mode != "L":
350+
raise ValueError("Image must be in mode L.")
348351
imwidth, imheight = img.size
349352
if imwidth != self.width or imheight != self.height:
350-
raise ValueError('Image must be same dimensions as display ({0}x{1}).' \
351-
.format(self.width, self.height))
353+
raise ValueError(
354+
"Image must be same dimensions as display ({0}x{1}).".format(
355+
self.width, self.height
356+
)
357+
)
352358
# Grab all the pixels from the image, faster than getpixel.
353359
pixels = img.load()
354360

355361
# Iterate through the pixels
356-
for x in range(self.width): # yes this double loop is slow,
362+
for x in range(self.width): # yes this double loop is slow,
357363
for y in range(self.height): # but these displays are small!
358364
self.pixel(x, y, pixels[(x, y)], blink=blink, frame=frame)
359365

360366

361367
class CharlieWing(Matrix):
362368
"""Supports the Charlieplexed feather wing
363369
"""
370+
364371
width = 15
365372
height = 7
366373

@@ -378,19 +385,21 @@ def pixel_addr(x, y):
378385

379386
class CharlieBonnet(Matrix):
380387
"""Supports the Charlieplexed bonnet"""
388+
381389
width = 16
382390
height = 8
383391

384392
@staticmethod
385393
def pixel_addr(x, y):
386394
"""Calulate the offset into the device array for x,y pixel"""
387395
if x >= 8:
388-
return (x-6) * 16 - (y + 1)
389-
return (x+1) * 16 + (7 - y)
396+
return (x - 6) * 16 - (y + 1)
397+
return (x + 1) * 16 + (7 - y)
390398

391399

392400
class ScrollPhatHD(Matrix):
393401
"""Supports the Scroll pHAT HD by Pimoroni"""
402+
394403
width = 17
395404
height = 7
396405

docs/conf.py

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,55 @@
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.viewcode',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.viewcode",
1617
]
1718

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

23-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
24+
intersphinx_mapping = {
25+
"python": ("https://docs.python.org/3.4", None),
26+
"BusDevice": (
27+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
28+
None,
29+
),
30+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
31+
}
2432

2533
# Add any paths that contain templates here, relative to this directory.
26-
templates_path = ['_templates']
34+
templates_path = ["_templates"]
2735

28-
source_suffix = '.rst'
36+
source_suffix = ".rst"
2937

3038
# The master toctree document.
31-
master_doc = 'index'
39+
master_doc = "index"
3240

3341
# General information about the project.
34-
project = u'Adafruit IS31FL3731 Library'
35-
copyright = u'2017 Radomir Dopieralski'
36-
author = u'Radomir Dopieralski'
42+
project = u"Adafruit IS31FL3731 Library"
43+
copyright = u"2017 Radomir Dopieralski"
44+
author = u"Radomir Dopieralski"
3745

3846
# The version info for the project you're documenting, acts as replacement for
3947
# |version| and |release|, also used in various other places throughout the
4048
# built documents.
4149
#
4250
# The short X.Y version.
43-
version = u'1.0'
51+
version = u"1.0"
4452
# The full version, including alpha/beta/rc tags.
45-
release = u'1.0'
53+
release = u"1.0"
4654

4755
# The language for content autogenerated by Sphinx. Refer to documentation
4856
# for a list of supported languages.
@@ -54,7 +62,7 @@
5462
# List of patterns, relative to source directory, that match files and
5563
# directories to ignore when looking for source files.
5664
# This patterns also effect to html_static_path and html_extra_path
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
65+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5866

5967
# The reST default role (used for this markup: `text`) to use for all
6068
# documents.
@@ -66,7 +74,7 @@
6674
add_function_parentheses = True
6775

6876
# The name of the Pygments (syntax highlighting) style to use.
69-
pygments_style = 'sphinx'
77+
pygments_style = "sphinx"
7078

7179
# If true, `todo` and `todoList` produce output, else they produce nothing.
7280
todo_include_todos = False
@@ -80,68 +88,76 @@
8088
# The theme to use for HTML and HTML Help pages. See the documentation for
8189
# a list of builtin themes.
8290
#
83-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8492

8593
if not on_rtd: # only import and set the theme if we're building docs locally
8694
try:
8795
import sphinx_rtd_theme
88-
html_theme = 'sphinx_rtd_theme'
89-
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(), "."]
9099
except:
91-
html_theme = 'default'
92-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
93102
else:
94-
html_theme_path = ['.']
103+
html_theme_path = ["."]
95104

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

101110
# The name of an image file (relative to this directory) to use as a favicon of
102111
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
103112
# pixels large.
104113
#
105-
html_favicon = '_static/favicon.ico'
114+
html_favicon = "_static/favicon.ico"
106115

107116
# Output file base name for HTML help builder.
108-
htmlhelp_basename = 'AdafruitIS31FL3731Librarydoc'
117+
htmlhelp_basename = "AdafruitIS31FL3731Librarydoc"
109118

110119
# -- Options for LaTeX output ---------------------------------------------
111120

112121
latex_elements = {
113-
# The paper size ('letterpaper' or 'a4paper').
114-
#
115-
# 'papersize': 'letterpaper',
116-
117-
# The font size ('10pt', '11pt' or '12pt').
118-
#
119-
# 'pointsize': '10pt',
120-
121-
# Additional stuff for the LaTeX preamble.
122-
#
123-
# 'preamble': '',
124-
125-
# Latex figure (float) alignment
126-
#
127-
# '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',
128134
}
129135

130136
# Grouping the document tree into LaTeX files. List of tuples
131137
# (source start file, target name, title,
132138
# author, documentclass [howto, manual, or own class]).
133139
latex_documents = [
134-
(master_doc, 'AdafruitIS31FL3731Library.tex', u'Adafruit IS31FL3731 Library Documentation',
135-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitIS31FL3731Library.tex",
143+
u"Adafruit IS31FL3731 Library Documentation",
144+
author,
145+
"manual",
146+
),
136147
]
137148

138149
# -- Options for manual page output ---------------------------------------
139150

140151
# One entry per manual page. List of tuples
141152
# (source start file, name, description, authors, manual section).
142153
man_pages = [
143-
(master_doc, 'adafruitIS31FL3731library', u'Adafruit IS31FL3731 Library Documentation',
144-
[author], 1)
154+
(
155+
master_doc,
156+
"adafruitIS31FL3731library",
157+
u"Adafruit IS31FL3731 Library Documentation",
158+
[author],
159+
1,
160+
)
145161
]
146162

147163
# -- Options for Texinfo output -------------------------------------------
@@ -150,7 +166,13 @@
150166
# (source start file, target name, title, author,
151167
# dir menu entry, description, category)
152168
texinfo_documents = [
153-
(master_doc, 'AdafruitIS31FL3731Library', u'Adafruit IS31FL3731 Library Documentation',
154-
author, 'AdafruitIS31FL3731Library', 'One line description of project.',
155-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitIS31FL3731Library",
172+
u"Adafruit IS31FL3731 Library Documentation",
173+
author,
174+
"AdafruitIS31FL3731Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
156178
]

0 commit comments

Comments
 (0)