Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Commit 087c004

Browse files
authored
Merge pull request #12 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 53e029a + 88046d9 commit 087c004

File tree

4 files changed

+121
-94
lines changed

4 files changed

+121
-94
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_pypixelbuf.py

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
DOTSTAR_LED_BRIGHTNESS = 0b00011111
3636

3737

38-
class PixelBuf(object): # pylint: disable=too-many-instance-attributes
38+
class PixelBuf: # pylint: disable=too-many-instance-attributes
3939
"""
4040
A sequence of RGB/RGBW pixels.
4141
@@ -49,8 +49,17 @@ class PixelBuf(object): # pylint: disable=too-many-instance-attributes
4949
:param ~int offset: Offset from start of buffer (default 0)
5050
:param ~bool auto_write: Whether to automatically write pixels (Default False)
5151
"""
52-
def __init__(self, n, buf, byteorder="BGR", brightness=1.0, # pylint: disable=too-many-locals,too-many-arguments
53-
rawbuf=None, offset=0, auto_write=False):
52+
53+
def __init__( # pylint: disable=too-many-locals,too-many-arguments
54+
self,
55+
n,
56+
buf,
57+
byteorder="BGR",
58+
brightness=1.0,
59+
rawbuf=None,
60+
offset=0,
61+
auto_write=False,
62+
):
5463

5564
bpp, byteorder_tuple, has_white, dotstar_mode = self.parse_byteorder(byteorder)
5665
if not isinstance(buf, bytearray):
@@ -67,7 +76,7 @@ def __init__(self, n, buf, byteorder="BGR", brightness=1.0, # pylint: disable=t
6776
if (len(buf) + offset) < _bytes:
6877
raise TypeError("buf is too small")
6978
if two_buffers and (len(rawbuf) + offset) < _bytes:
70-
raise TypeError("buf is too small. need %d bytes" % (_bytes, ))
79+
raise TypeError("buf is too small. need %d bytes" % (_bytes,))
7180

7281
self._pixels = n
7382
self._bytes = _bytes
@@ -85,8 +94,12 @@ def __init__(self, n, buf, byteorder="BGR", brightness=1.0, # pylint: disable=t
8594
self.auto_write = auto_write
8695

8796
if dotstar_mode:
88-
self._byteorder_tuple = (byteorder_tuple[0] + 1, byteorder_tuple[1] + 1,
89-
byteorder_tuple[2] + 1, 0)
97+
self._byteorder_tuple = (
98+
byteorder_tuple[0] + 1,
99+
byteorder_tuple[1] + 1,
100+
byteorder_tuple[2] + 1,
101+
0,
102+
)
90103

91104
self._brightness = min(1.0, max(0, brightness))
92105

@@ -128,10 +141,10 @@ def parse_byteorder(byteorder):
128141
b = byteorder.index("B")
129142
except ValueError:
130143
raise ValueError("Invalid Byteorder string")
131-
if 'W' in byteorder:
144+
if "W" in byteorder:
132145
w = byteorder.index("W")
133146
byteorder = (r, g, b, w)
134-
elif 'P' in byteorder:
147+
elif "P" in byteorder:
135148
lum = byteorder.index("P")
136149
byteorder = (r, g, b, lum)
137150
dotstar_mode = True
@@ -192,7 +205,9 @@ def show(self):
192205
"""
193206
raise NotImplementedError("Must be subclassed")
194207

195-
def _set_item(self, index, value): # pylint: disable=too-many-locals,too-many-branches
208+
def _set_item(
209+
self, index, value
210+
): # pylint: disable=too-many-locals,too-many-branches
196211
if index < 0:
197212
index += len(self)
198213
if index >= self._pixels or index < 0:
@@ -205,8 +220,8 @@ def _set_item(self, index, value): # pylint: disable=too-many-locals,too-many-b
205220
has_w = False
206221
if isinstance(value, int):
207222
r = value >> 16
208-
g = (value >> 8) & 0xff
209-
b = value & 0xff
223+
g = (value >> 8) & 0xFF
224+
b = value & 0xFF
210225
w = 0
211226
# If all components are the same and we have a white pixel then use it
212227
# instead of the individual components.
@@ -243,12 +258,14 @@ def _set_item(self, index, value): # pylint: disable=too-many-locals,too-many-b
243258
# same as math.ceil(brightness * 31) & 0b00011111
244259
# Idea from https://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions
245260
self._bytearray[offset + self._byteorder[3]] = (
246-
32 - int(32 - w * 31) & 0b00011111) | DOTSTAR_LED_START
261+
32 - int(32 - w * 31) & 0b00011111
262+
) | DOTSTAR_LED_START
247263
else:
248264
self._bytearray[offset + self._byteorder[3]] = int(w * self._brightness)
249265
if self._two_buffers:
250266
self._rawbytearray[offset + self._byteorder[3]] = self._bytearray[
251-
offset + self._byteorder[3]]
267+
offset + self._byteorder[3]
268+
]
252269
elif self._dotstar_mode:
253270
self._bytearray[offset + self._byteorder[3]] = DOTSTAR_LED_START_FULL_BRIGHT
254271

@@ -273,8 +290,10 @@ def _getitem(self, index):
273290
if self._has_white:
274291
value.append(self._bytearray[start + self._byteorder[2]])
275292
elif self._dotstar_mode:
276-
value.append((self._bytearray[start + self._byteorder[3]] & DOTSTAR_LED_BRIGHTNESS) /
277-
31.0)
293+
value.append(
294+
(self._bytearray[start + self._byteorder[3]] & DOTSTAR_LED_BRIGHTNESS)
295+
/ 31.0
296+
)
278297
return value
279298

280299
def __getitem__(self, index):

docs/conf.py

Lines changed: 65 additions & 47 deletions
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 = ["digitalio", "busio"]
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 PyPixelBuf Library'
38-
copyright = u'2020 Roy Hooper'
39-
author = u'Roy Hooper'
41+
project = u"Adafruit PyPixelBuf Library"
42+
copyright = u"2020 Roy Hooper"
43+
author = u"Roy Hooper"
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 = 'AdafruitPypixelbufLibrarydoc'
117+
htmlhelp_basename = "AdafruitPypixelbufLibrarydoc"
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, 'AdafruitPyPixelBufLibrary.tex', u'AdafruitPyPixelBuf Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitPyPixelBufLibrary.tex",
143+
u"AdafruitPyPixelBuf 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, 'AdafruitPyPixelBuflibrary', u'Adafruit PyPixelBuf Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitPyPixelBuflibrary",
157+
u"Adafruit PyPixelBuf 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, 'AdafruitPyPixelBufLibrary', u'Adafruit PyPixelBuf Library Documentation',
158-
author, 'AdafruitPyPixelBufLibrary', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitPyPixelBufLibrary",
172+
u"Adafruit PyPixelBuf Library Documentation",
173+
author,
174+
"AdafruitPyPixelBufLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

0 commit comments

Comments
 (0)