Skip to content

Commit 62e645e

Browse files
authored
Merge pull request #45 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents d8ccc5a + 11e1095 commit 62e645e

File tree

8 files changed

+180
-136
lines changed

8 files changed

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

.pylintrc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ignore-patterns=
1818
#init-hook=
1919

2020
# Use multiple processes to speed up Pylint.
21+
# jobs=1
2122
jobs=2
2223

2324
# List of plugins (as comma separated values of python modules names) to load,
@@ -50,7 +51,8 @@ confidence=
5051
# --enable=similarities". If you want to run only the classes checker, but have
5152
# no Warning level messages displayed, use"--disable=all --enable=classes
5253
# --disable=W"
53-
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error
54+
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
55+
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation
5456

5557
# Enable the message, report, category or checker with the given id(s). You can
5658
# either give multiple identifier separated by comma (,) or put this option
@@ -117,7 +119,8 @@ spelling-store-unknown-words=no
117119
[MISCELLANEOUS]
118120

119121
# List of note tags to take in consideration, separated by a comma.
120-
notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123+
notes=FIXME,XXX
121124

122125

123126
[TYPECHECK]
@@ -200,6 +203,7 @@ redefining-builtins-modules=six.moves,future.builtins
200203
[FORMAT]
201204

202205
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
206+
# expected-line-ending-format=
203207
expected-line-ending-format=LF
204208

205209
# Regexp for a line that is allowed to be longer than the limit.
@@ -272,9 +276,11 @@ class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
272276
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
273277

274278
# Naming hint for class names
279+
# class-name-hint=[A-Z_][a-zA-Z0-9]+$
275280
class-name-hint=[A-Z_][a-zA-Z0-9_]+$
276281

277282
# Regular expression matching correct class names
283+
# class-rgx=[A-Z_][a-zA-Z0-9]+$
278284
class-rgx=[A-Z_][a-zA-Z0-9_]+$
279285

280286
# Naming hint for constant names
@@ -294,7 +300,8 @@ function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
294300
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
295301

296302
# Good variable names which should always be accepted, separated by a comma
297-
good-names=r,g,b,i,j,k,n,ex,Run,_
303+
# good-names=i,j,k,ex,Run,_
304+
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
298305

299306
# Include a hint for the correct naming format with invalid-name
300307
include-naming-hint=no
@@ -391,6 +398,7 @@ valid-metaclass-classmethod-first-arg=mcs
391398
max-args=5
392399

393400
# Maximum number of attributes for a class (see R0902).
401+
# max-attributes=7
394402
max-attributes=11
395403

396404
# Maximum number of boolean expressions in a if statement
@@ -415,7 +423,7 @@ max-returns=6
415423
max-statements=50
416424

417425
# Minimum number of public methods for a class (see R0903).
418-
min-public-methods=2
426+
min-public-methods=1
419427

420428

421429
[EXCEPTIONS]

adafruit_dotstar.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,17 @@ class DotStar:
8181
time.sleep(2)
8282
"""
8383

84-
def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True,
85-
pixel_order=BGR, baudrate=4000000):
84+
def __init__(
85+
self,
86+
clock,
87+
data,
88+
n,
89+
*,
90+
brightness=1.0,
91+
auto_write=True,
92+
pixel_order=BGR,
93+
baudrate=4000000
94+
):
8695
self._spi = None
8796
try:
8897
self._spi = busio.SPI(clock, MOSI=data)
@@ -109,10 +118,10 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True,
109118
self._buf[i] = 0x00
110119
# Mark the beginnings of each pixel.
111120
for i in range(START_HEADER_SIZE, self.end_header_index, 4):
112-
self._buf[i] = 0xff
121+
self._buf[i] = 0xFF
113122
# 0xff bytes at the end.
114123
for i in range(self.end_header_index, len(self._buf)):
115-
self._buf[i] = 0xff
124+
self._buf[i] = 0xFF
116125
self._brightness = 1.0
117126
# Set auto_write to False temporarily so brightness setter does _not_
118127
# call show() while in __init__.
@@ -162,7 +171,7 @@ def _set_item(self, index, value):
162171
offset = index * 4 + START_HEADER_SIZE
163172
rgb = value
164173
if isinstance(value, int):
165-
rgb = (value >> 16, (value >> 8) & 0xff, value & 0xff)
174+
rgb = (value >> 16, (value >> 8) & 0xFF, value & 0xFF)
166175

167176
if len(rgb) == 4:
168177
brightness = value[3]
@@ -204,15 +213,18 @@ def __getitem__(self, index):
204213
out = []
205214
for in_i in range(*index.indices(self._n)):
206215
out.append(
207-
tuple(self._buf[in_i * 4 + (3 - i) + START_HEADER_SIZE] for i in range(3)))
216+
tuple(
217+
self._buf[in_i * 4 + (3 - i) + START_HEADER_SIZE]
218+
for i in range(3)
219+
)
220+
)
208221
return out
209222
if index < 0:
210223
index += len(self)
211224
if index >= self._n or index < 0:
212225
raise IndexError
213226
offset = index * 4
214-
return tuple(self._buf[offset + (3 - i) + START_HEADER_SIZE]
215-
for i in range(3))
227+
return tuple(self._buf[offset + (3 - i) + START_HEADER_SIZE] for i in range(3))
216228

217229
def __len__(self):
218230
return self._n
@@ -241,7 +253,7 @@ def fill(self, color):
241253
def _ds_writebytes(self, buf):
242254
for b in buf:
243255
for _ in range(8):
244-
self.dpin.value = (b & 0x80)
256+
self.dpin.value = b & 0x80
245257
self.cpin.value = True
246258
self.cpin.value = False
247259
b = b << 1
@@ -260,10 +272,12 @@ def show(self):
260272
for i in range(START_HEADER_SIZE):
261273
buf[i] = 0x00
262274
for i in range(START_HEADER_SIZE, self.end_header_index):
263-
buf[i] = self._buf[i] if i % 4 == 0 else int(self._buf[i] * self._brightness)
275+
buf[i] = (
276+
self._buf[i] if i % 4 == 0 else int(self._buf[i] * self._brightness)
277+
)
264278
# Four 0xff bytes at the end.
265279
for i in range(self.end_header_index, len(buf)):
266-
buf[i] = 0xff
280+
buf[i] = 0xFF
267281

268282
if self._spi:
269283
self._spi.write(buf)

docs/conf.py

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,48 @@
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
# autodoc_mock_imports = ["digitalio", "busio"]
1920

20-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
21-
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
21+
intersphinx_mapping = {
22+
"python": ("https://docs.python.org/3.4", None),
23+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
24+
}
2225

2326
# Add any paths that contain templates here, relative to this directory.
24-
templates_path = ['_templates']
27+
templates_path = ["_templates"]
2528

26-
source_suffix = '.rst'
29+
source_suffix = ".rst"
2730

2831
# The master toctree document.
29-
master_doc = 'index'
32+
master_doc = "index"
3033

3134
# General information about the project.
32-
project = u'Adafruit CircuitPython DotStar Library'
33-
copyright = u'2017 Scott Shawcroft, Limor Fried & Damien P. George'
34-
author = u'Scott Shawcroft, Limor Fried & Damien P. George'
35+
project = u"Adafruit CircuitPython DotStar Library"
36+
copyright = u"2017 Scott Shawcroft, Limor Fried & Damien P. George"
37+
author = u"Scott Shawcroft, Limor Fried & Damien P. George"
3538

3639
# The version info for the project you're documenting, acts as replacement for
3740
# |version| and |release|, also used in various other places throughout the
3841
# built documents.
3942
#
4043
# The short X.Y version.
41-
version = u'1.0'
44+
version = u"1.0"
4245
# The full version, including alpha/beta/rc tags.
43-
release = u'1.0'
46+
release = u"1.0"
4447

4548
# The language for content autogenerated by Sphinx. Refer to documentation
4649
# for a list of supported languages.
@@ -52,7 +55,7 @@
5255
# List of patterns, relative to source directory, that match files and
5356
# directories to ignore when looking for source files.
5457
# This patterns also effect to html_static_path and html_extra_path
55-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
58+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5659

5760
# The reST default role (used for this markup: `text`) to use for all
5861
# documents.
@@ -64,7 +67,7 @@
6467
add_function_parentheses = True
6568

6669
# The name of the Pygments (syntax highlighting) style to use.
67-
pygments_style = 'sphinx'
70+
pygments_style = "sphinx"
6871

6972
# If true, `todo` and `todoList` produce output, else they produce nothing.
7073
todo_include_todos = False
@@ -78,68 +81,76 @@
7881
# The theme to use for HTML and HTML Help pages. See the documentation for
7982
# a list of builtin themes.
8083
#
81-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
84+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8285

8386
if not on_rtd: # only import and set the theme if we're building docs locally
8487
try:
8588
import sphinx_rtd_theme
86-
html_theme = 'sphinx_rtd_theme'
87-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
89+
90+
html_theme = "sphinx_rtd_theme"
91+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
8892
except:
89-
html_theme = 'default'
90-
html_theme_path = ['.']
93+
html_theme = "default"
94+
html_theme_path = ["."]
9195
else:
92-
html_theme_path = ['.']
96+
html_theme_path = ["."]
9397

9498
# Add any paths that contain custom static files (such as style sheets) here,
9599
# relative to this directory. They are copied after the builtin static files,
96100
# so a file named "default.css" will overwrite the builtin "default.css".
97-
html_static_path = ['_static']
101+
html_static_path = ["_static"]
98102

99103
# The name of an image file (relative to this directory) to use as a favicon of
100104
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
101105
# pixels large.
102106
#
103-
html_favicon = '_static/favicon.ico'
107+
html_favicon = "_static/favicon.ico"
104108

105109
# Output file base name for HTML help builder.
106-
htmlhelp_basename = 'AdafruitDotStarLibrarydoc'
110+
htmlhelp_basename = "AdafruitDotStarLibrarydoc"
107111

108112
# -- Options for LaTeX output ---------------------------------------------
109113

110114
latex_elements = {
111-
# The paper size ('letterpaper' or 'a4paper').
112-
#
113-
# 'papersize': 'letterpaper',
114-
115-
# The font size ('10pt', '11pt' or '12pt').
116-
#
117-
# 'pointsize': '10pt',
118-
119-
# Additional stuff for the LaTeX preamble.
120-
#
121-
# 'preamble': '',
122-
123-
# Latex figure (float) alignment
124-
#
125-
# 'figure_align': 'htbp',
115+
# The paper size ('letterpaper' or 'a4paper').
116+
#
117+
# 'papersize': 'letterpaper',
118+
# The font size ('10pt', '11pt' or '12pt').
119+
#
120+
# 'pointsize': '10pt',
121+
# Additional stuff for the LaTeX preamble.
122+
#
123+
# 'preamble': '',
124+
# Latex figure (float) alignment
125+
#
126+
# 'figure_align': 'htbp',
126127
}
127128

128129
# Grouping the document tree into LaTeX files. List of tuples
129130
# (source start file, target name, title,
130131
# author, documentclass [howto, manual, or own class]).
131132
latex_documents = [
132-
(master_doc, 'AdafruitDotStarLibrary.tex', u'Adafruit DotStar Library Documentation',
133-
author, 'manual'),
133+
(
134+
master_doc,
135+
"AdafruitDotStarLibrary.tex",
136+
u"Adafruit DotStar Library Documentation",
137+
author,
138+
"manual",
139+
),
134140
]
135141

136142
# -- Options for manual page output ---------------------------------------
137143

138144
# One entry per manual page. List of tuples
139145
# (source start file, name, description, authors, manual section).
140146
man_pages = [
141-
(master_doc, 'adafruitDotStarlibrary', u'Adafruit DotStar Library Documentation',
142-
[author], 1)
147+
(
148+
master_doc,
149+
"adafruitDotStarlibrary",
150+
u"Adafruit DotStar Library Documentation",
151+
[author],
152+
1,
153+
)
143154
]
144155

145156
# -- Options for Texinfo output -------------------------------------------
@@ -148,7 +159,13 @@
148159
# (source start file, target name, title, author,
149160
# dir menu entry, description, category)
150161
texinfo_documents = [
151-
(master_doc, 'AdafruitDotStarLibrary', u'Adafruit DotStar Library Documentation',
152-
author, 'AdafruitDotStarLibrary', 'One line description of project.',
153-
'Miscellaneous'),
162+
(
163+
master_doc,
164+
"AdafruitDotStarLibrary",
165+
u"Adafruit DotStar Library Documentation",
166+
author,
167+
"AdafruitDotStarLibrary",
168+
"One line description of project.",
169+
"Miscellaneous",
170+
),
154171
]

0 commit comments

Comments
 (0)