Skip to content

Commit 208bb37

Browse files
authored
Merge pull request #12 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 18a4f73 + ddc965d commit 208bb37

File tree

5 files changed

+118
-99
lines changed

5 files changed

+118
-99
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

docs/conf.py

+69-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,36 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
2425

2526

26-
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)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"BusDevice": (
30+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
31+
None,
32+
),
33+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
34+
}
2735

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

31-
source_suffix = '.rst'
39+
source_suffix = ".rst"
3240

3341
# The master toctree document.
34-
master_doc = 'index'
42+
master_doc = "index"
3543

3644
# General information about the project.
37-
project = u'Adafruit NeoPixel_SPI Library'
38-
copyright = u'2019 Carter Nelson'
39-
author = u'Carter Nelson'
45+
project = u"Adafruit NeoPixel_SPI Library"
46+
copyright = u"2019 Carter Nelson"
47+
author = u"Carter Nelson"
4048

4149
# The version info for the project you're documenting, acts as replacement for
4250
# |version| and |release|, also used in various other places throughout the
4351
# built documents.
4452
#
4553
# The short X.Y version.
46-
version = u'1.0'
54+
version = u"1.0"
4755
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
56+
release = u"1.0"
4957

5058
# The language for content autogenerated by Sphinx. Refer to documentation
5159
# for a list of supported languages.
@@ -57,7 +65,7 @@
5765
# List of patterns, relative to source directory, that match files and
5866
# directories to ignore when looking for source files.
5967
# 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']
68+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6169

6270
# The reST default role (used for this markup: `text`) to use for all
6371
# documents.
@@ -69,7 +77,7 @@
6977
add_function_parentheses = True
7078

7179
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
80+
pygments_style = "sphinx"
7381

7482
# If true, `todo` and `todoList` produce output, else they produce nothing.
7583
todo_include_todos = False
@@ -84,68 +92,76 @@
8492
# The theme to use for HTML and HTML Help pages. See the documentation for
8593
# a list of builtin themes.
8694
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
95+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8896

8997
if not on_rtd: # only import and set the theme if we're building docs locally
9098
try:
9199
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
100+
101+
html_theme = "sphinx_rtd_theme"
102+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94103
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
104+
html_theme = "default"
105+
html_theme_path = ["."]
97106
else:
98-
html_theme_path = ['.']
107+
html_theme_path = ["."]
99108

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

105114
# The name of an image file (relative to this directory) to use as a favicon of
106115
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107116
# pixels large.
108117
#
109-
html_favicon = '_static/favicon.ico'
118+
html_favicon = "_static/favicon.ico"
110119

111120
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitNeopixel_spiLibrarydoc'
121+
htmlhelp_basename = "AdafruitNeopixel_spiLibrarydoc"
113122

114123
# -- Options for LaTeX output ---------------------------------------------
115124

116125
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',
126+
# The paper size ('letterpaper' or 'a4paper').
127+
#
128+
# 'papersize': 'letterpaper',
129+
# The font size ('10pt', '11pt' or '12pt').
130+
#
131+
# 'pointsize': '10pt',
132+
# Additional stuff for the LaTeX preamble.
133+
#
134+
# 'preamble': '',
135+
# Latex figure (float) alignment
136+
#
137+
# 'figure_align': 'htbp',
132138
}
133139

134140
# Grouping the document tree into LaTeX files. List of tuples
135141
# (source start file, target name, title,
136142
# author, documentclass [howto, manual, or own class]).
137143
latex_documents = [
138-
(master_doc, 'AdafruitNeoPixel_SPILibrary.tex', u'AdafruitNeoPixel_SPI Library Documentation',
139-
author, 'manual'),
144+
(
145+
master_doc,
146+
"AdafruitNeoPixel_SPILibrary.tex",
147+
u"AdafruitNeoPixel_SPI Library Documentation",
148+
author,
149+
"manual",
150+
),
140151
]
141152

142153
# -- Options for manual page output ---------------------------------------
143154

144155
# One entry per manual page. List of tuples
145156
# (source start file, name, description, authors, manual section).
146157
man_pages = [
147-
(master_doc, 'AdafruitNeoPixel_SPIlibrary', u'Adafruit NeoPixel_SPI Library Documentation',
148-
[author], 1)
158+
(
159+
master_doc,
160+
"AdafruitNeoPixel_SPIlibrary",
161+
u"Adafruit NeoPixel_SPI Library Documentation",
162+
[author],
163+
1,
164+
)
149165
]
150166

151167
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +170,13 @@
154170
# (source start file, target name, title, author,
155171
# dir menu entry, description, category)
156172
texinfo_documents = [
157-
(master_doc, 'AdafruitNeoPixel_SPILibrary', u'Adafruit NeoPixel_SPI Library Documentation',
158-
author, 'AdafruitNeoPixel_SPILibrary', 'One line description of project.',
159-
'Miscellaneous'),
173+
(
174+
master_doc,
175+
"AdafruitNeoPixel_SPILibrary",
176+
u"Adafruit NeoPixel_SPI Library Documentation",
177+
author,
178+
"AdafruitNeoPixel_SPILibrary",
179+
"One line description of project.",
180+
"Miscellaneous",
181+
),
160182
]

examples/neopixel_spi_simpletest.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
spi = board.SPI()
1111

12-
pixels = neopixel.NeoPixel_SPI(spi,
13-
NUM_PIXELS,
14-
pixel_order=PIXEL_ORDER,
15-
auto_write=False)
12+
pixels = neopixel.NeoPixel_SPI(
13+
spi, NUM_PIXELS, pixel_order=PIXEL_ORDER, auto_write=False
14+
)
1615

1716
while True:
1817
for color in COLORS:

neopixel_spi.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,23 @@
4343
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
4444
"""
4545

46-
from adafruit_pypixelbuf import PixelBuf, fill
4746
from adafruit_bus_device.spi_device import SPIDevice
47+
from adafruit_pypixelbuf import PixelBuf, fill
4848

4949
__version__ = "0.0.0-auto.0"
5050
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel_SPI.git"
5151

5252
# Pixel color order constants
53-
RGB = 'RGB'
53+
RGB = "RGB"
5454
"""Red Green Blue"""
55-
GRB = 'GRB'
55+
GRB = "GRB"
5656
"""Green Red Blue"""
57-
RGBW = 'RGBW'
57+
RGBW = "RGBW"
5858
"""Red Green Blue White"""
59-
GRBW = 'GRBW'
59+
GRBW = "GRBW"
6060
"""Green Red Blue White"""
6161

62+
6263
class NeoPixel_SPI(PixelBuf):
6364
"""
6465
A sequence of neopixels.
@@ -84,9 +85,11 @@ class NeoPixel_SPI(PixelBuf):
8485
"""
8586

8687
FREQ = 6400000 # 800kHz * 8, actual may be different
87-
TRST = 80e-6 # Reset code low level time
88+
TRST = 80e-6 # Reset code low level time
8889

89-
def __init__(self, spi, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None):
90+
def __init__(
91+
self, spi, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None
92+
):
9093

9194
# configure bpp and pixel_order
9295
if not pixel_order:
@@ -103,15 +106,18 @@ def __init__(self, spi, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_orde
103106
except AttributeError:
104107
# use nominal
105108
freq = self.FREQ
106-
self._reset = bytes([0]*round(freq * self.TRST / 8))
109+
self._reset = bytes([0] * round(freq * self.TRST / 8))
107110
self.spibuf = bytearray(8 * n * bpp)
108111

109112
# everything else taken care of by base class
110-
super().__init__(n, bytearray(n * bpp),
111-
brightness=brightness,
112-
rawbuf=bytearray(n * bpp),
113-
byteorder=pixel_order,
114-
auto_write=auto_write)
113+
super().__init__(
114+
n,
115+
bytearray(n * bpp),
116+
brightness=brightness,
117+
rawbuf=bytearray(n * bpp),
118+
byteorder=pixel_order,
119+
auto_write=auto_write,
120+
)
115121

116122
def deinit(self):
117123
"""Blank out the NeoPixels."""
@@ -122,7 +128,7 @@ def show(self):
122128
"""Shows the new colors on the pixels themselves if they haven't already
123129
been autowritten."""
124130
self._transmogrify()
125-
#pylint: disable=no-member
131+
# pylint: disable=no-member
126132
with self._spi as spi:
127133
# write out special byte sequence surrounded by RESET
128134
# leading RESET needed for cases where MOSI rests HI
@@ -136,9 +142,9 @@ def _transmogrify(self):
136142
# MSB first
137143
for i in range(7, -1, -1):
138144
if byte >> i & 0x01:
139-
self.spibuf[k] = 0b11110000 # A NeoPixel 1 bit
145+
self.spibuf[k] = 0b11110000 # A NeoPixel 1 bit
140146
else:
141-
self.spibuf[k] = 0b11000000 # A NeoPixel 0 bit
147+
self.spibuf[k] = 0b11000000 # A NeoPixel 0 bit
142148
k += 1
143149

144150
def fill(self, color):

0 commit comments

Comments
 (0)