Skip to content

Commit 5044758

Browse files
authored
Merge pull request #27 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 4359a50 + 9657e51 commit 5044758

File tree

5 files changed

+139
-98
lines changed

5 files changed

+139
-98
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_crickit.py

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747

4848
from micropython import const
4949

50-
#pylint: disable=wrong-import-position
50+
# pylint: disable=wrong-import-position
5151
try:
52-
lib_index = sys.path.index("/lib") # pylint: disable=invalid-name
52+
lib_index = sys.path.index("/lib") # pylint: disable=invalid-name
5353
if lib_index < sys.path.index(".frozen"):
5454
# Prefer frozen modules over those in /lib.
5555
sys.path.insert(lib_index, ".frozen")
@@ -95,9 +95,10 @@
9595
_NEOPIXEL = const(20)
9696
_SS_PIXEL = const(27)
9797

98-
#pylint: disable=too-few-public-methods
98+
# pylint: disable=too-few-public-methods
9999
class CrickitTouchIn:
100100
"""Imitate touchio.TouchIn."""
101+
101102
def __init__(self, seesaw, pin):
102103
self._seesaw = seesaw
103104
self._pin = pin
@@ -114,7 +115,7 @@ def value(self):
114115
return self.raw_value > self.threshold
115116

116117

117-
#pylint: disable=too-many-public-methods
118+
# pylint: disable=too-many-public-methods
118119
class Crickit:
119120
"""Represents a Crickit board. Provides a number of devices available via properties, such as
120121
``servo_1``. Devices are created on demand the first time they are referenced.
@@ -260,7 +261,9 @@ def feather_drive_stepper_motor(self):
260261
def _motor(self, terminals, motor_class):
261262
device = self._devices.get(terminals, None)
262263
if not isinstance(device, motor_class):
263-
device = motor_class(*(PWMOut(self._seesaw, terminal) for terminal in terminals))
264+
device = motor_class(
265+
*(PWMOut(self._seesaw, terminal) for terminal in terminals)
266+
)
264267
self._devices[terminals] = device
265268
return device
266269

@@ -345,8 +348,9 @@ def neopixel(self):
345348
raise ValueError("Call init_neopixel first")
346349
return self._neopixel
347350

348-
349-
def init_neopixel(self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None):
351+
def init_neopixel(
352+
self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None
353+
):
350354
"""Set up a seesaw.NeoPixel object
351355
352356
.. note:: On the CPX Crickit board, the NeoPixel terminal is by default
@@ -366,31 +370,50 @@ def init_neopixel(self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_orde
366370
crickit.init_neopixel(24)
367371
crickit.neopixel.fill((100, 0, 0))
368372
"""
369-
from adafruit_seesaw.neopixel import NeoPixel
370-
self._neopixel = NeoPixel(self._seesaw, _NEOPIXEL, n, bpp=bpp,
371-
brightness=brightness, auto_write=auto_write,
372-
pixel_order=pixel_order)
373+
from adafruit_seesaw.neopixel import ( # pylint: disable=import-outside-toplevel
374+
NeoPixel,
375+
)
376+
377+
self._neopixel = NeoPixel(
378+
self._seesaw,
379+
_NEOPIXEL,
380+
n,
381+
bpp=bpp,
382+
brightness=brightness,
383+
auto_write=auto_write,
384+
pixel_order=pixel_order,
385+
)
373386

374387
@property
375388
def onboard_pixel(self):
376389
"""```adafruit_seesaw.neopixel`` object on the Seesaw on-board NeoPixel.
377390
Initialize on-board NeoPixel and clear upon first use.
378391
"""
379392
if not self._onboard_pixel:
380-
from adafruit_seesaw.neopixel import NeoPixel
381-
self._onboard_pixel = NeoPixel(self._seesaw, _SS_PIXEL, 1, bpp=3,
382-
brightness=1.0, auto_write=True,
383-
pixel_order=None)
393+
from adafruit_seesaw.neopixel import ( # pylint: disable=import-outside-toplevel
394+
NeoPixel,
395+
)
396+
397+
self._onboard_pixel = NeoPixel(
398+
self._seesaw,
399+
_SS_PIXEL,
400+
1,
401+
bpp=3,
402+
brightness=1.0,
403+
auto_write=True,
404+
pixel_order=None,
405+
)
384406
self._onboard_pixel.fill((0, 0, 0))
385407
return self._onboard_pixel
386408

387409
def reset(self):
388410
"""Reset the whole Crickit board."""
389411
self._seesaw.sw_reset()
390412

391-
crickit = None # pylint: disable=invalid-name
413+
414+
crickit = None # pylint: disable=invalid-name
392415
"""A singleton instance to control a single Crickit board, controlled by the default I2C pins."""
393416

394417
# Sphinx's board is missing real pins so skip the constructor in that case.
395418
if "I2C" in dir(board):
396-
crickit = Crickit(Seesaw(board.I2C())) # pylint: disable=invalid-name
419+
crickit = Crickit(Seesaw(board.I2C())) # pylint: disable=invalid-name

docs/conf.py

Lines changed: 72 additions & 49 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

@@ -23,33 +24,41 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
27-
'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+
}
2831

2932
# Libraries we depend on but don't need for generating docs.
30-
autodoc_mock_imports = ['board', 'busio', 'micropython', 'adafruit_seesaw', 'adafruit_motor']
33+
autodoc_mock_imports = [
34+
"board",
35+
"busio",
36+
"micropython",
37+
"adafruit_seesaw",
38+
"adafruit_motor",
39+
]
3140

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

35-
source_suffix = '.rst'
44+
source_suffix = ".rst"
3645

3746
# The master toctree document.
38-
master_doc = 'index'
47+
master_doc = "index"
3948

4049
# General information about the project.
41-
project = u'Adafruit Crickit Library'
42-
copyright = u'2018 Dan Halbert'
43-
author = u'Dan Halbert'
50+
project = u"Adafruit Crickit Library"
51+
copyright = u"2018 Dan Halbert"
52+
author = u"Dan Halbert"
4453

4554
# The version info for the project you're documenting, acts as replacement for
4655
# |version| and |release|, also used in various other places throughout the
4756
# built documents.
4857
#
4958
# The short X.Y version.
50-
version = u'1.0'
59+
version = u"1.0"
5160
# The full version, including alpha/beta/rc tags.
52-
release = u'1.0'
61+
release = u"1.0"
5362

5463
# The language for content autogenerated by Sphinx. Refer to documentation
5564
# for a list of supported languages.
@@ -61,7 +70,7 @@
6170
# List of patterns, relative to source directory, that match files and
6271
# directories to ignore when looking for source files.
6372
# This patterns also effect to html_static_path and html_extra_path
64-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
73+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6574

6675
# The reST default role (used for this markup: `text`) to use for all
6776
# documents.
@@ -73,7 +82,7 @@
7382
add_function_parentheses = True
7483

7584
# The name of the Pygments (syntax highlighting) style to use.
76-
pygments_style = 'sphinx'
85+
pygments_style = "sphinx"
7786

7887
# If true, `todo` and `todoList` produce output, else they produce nothing.
7988
todo_include_todos = False
@@ -88,68 +97,76 @@
8897
# The theme to use for HTML and HTML Help pages. See the documentation for
8998
# a list of builtin themes.
9099
#
91-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
100+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
92101

93102
if not on_rtd: # only import and set the theme if we're building docs locally
94103
try:
95104
import sphinx_rtd_theme
96-
html_theme = 'sphinx_rtd_theme'
97-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
105+
106+
html_theme = "sphinx_rtd_theme"
107+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
98108
except:
99-
html_theme = 'default'
100-
html_theme_path = ['.']
109+
html_theme = "default"
110+
html_theme_path = ["."]
101111
else:
102-
html_theme_path = ['.']
112+
html_theme_path = ["."]
103113

104114
# Add any paths that contain custom static files (such as style sheets) here,
105115
# relative to this directory. They are copied after the builtin static files,
106116
# so a file named "default.css" will overwrite the builtin "default.css".
107-
html_static_path = ['_static']
117+
html_static_path = ["_static"]
108118

109119
# The name of an image file (relative to this directory) to use as a favicon of
110120
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
111121
# pixels large.
112122
#
113-
html_favicon = '_static/favicon.ico'
123+
html_favicon = "_static/favicon.ico"
114124

115125
# Output file base name for HTML help builder.
116-
htmlhelp_basename = 'AdafruitCrickitLibrarydoc'
126+
htmlhelp_basename = "AdafruitCrickitLibrarydoc"
117127

118128
# -- Options for LaTeX output ---------------------------------------------
119129

120130
latex_elements = {
121-
# The paper size ('letterpaper' or 'a4paper').
122-
#
123-
# 'papersize': 'letterpaper',
124-
125-
# The font size ('10pt', '11pt' or '12pt').
126-
#
127-
# 'pointsize': '10pt',
128-
129-
# Additional stuff for the LaTeX preamble.
130-
#
131-
# 'preamble': '',
132-
133-
# Latex figure (float) alignment
134-
#
135-
# 'figure_align': 'htbp',
131+
# The paper size ('letterpaper' or 'a4paper').
132+
#
133+
# 'papersize': 'letterpaper',
134+
# The font size ('10pt', '11pt' or '12pt').
135+
#
136+
# 'pointsize': '10pt',
137+
# Additional stuff for the LaTeX preamble.
138+
#
139+
# 'preamble': '',
140+
# Latex figure (float) alignment
141+
#
142+
# 'figure_align': 'htbp',
136143
}
137144

138145
# Grouping the document tree into LaTeX files. List of tuples
139146
# (source start file, target name, title,
140147
# author, documentclass [howto, manual, or own class]).
141148
latex_documents = [
142-
(master_doc, 'AdafruitCrickitLibrary.tex', u'AdafruitCrickit Library Documentation',
143-
author, 'manual'),
149+
(
150+
master_doc,
151+
"AdafruitCrickitLibrary.tex",
152+
u"AdafruitCrickit Library Documentation",
153+
author,
154+
"manual",
155+
),
144156
]
145157

146158
# -- Options for manual page output ---------------------------------------
147159

148160
# One entry per manual page. List of tuples
149161
# (source start file, name, description, authors, manual section).
150162
man_pages = [
151-
(master_doc, 'AdafruitCrickitLibrary', u'Adafruit Crickit Library Documentation',
152-
[author], 1)
163+
(
164+
master_doc,
165+
"AdafruitCrickitLibrary",
166+
u"Adafruit Crickit Library Documentation",
167+
[author],
168+
1,
169+
)
153170
]
154171

155172
# -- Options for Texinfo output -------------------------------------------
@@ -158,7 +175,13 @@
158175
# (source start file, target name, title, author,
159176
# dir menu entry, description, category)
160177
texinfo_documents = [
161-
(master_doc, 'AdafruitCrickitLibrary', u'Adafruit Crickit Library Documentation',
162-
author, 'AdafruitCrickitLibrary', 'One line description of project.',
163-
'Miscellaneous'),
178+
(
179+
master_doc,
180+
"AdafruitCrickitLibrary",
181+
u"Adafruit Crickit Library Documentation",
182+
author,
183+
"AdafruitCrickitLibrary",
184+
"One line description of project.",
185+
"Miscellaneous",
186+
),
164187
]

examples/crickit_drive_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# For Circuit Playground Express, micro:bit, and RPi Crickit, use:
88
drive_1 = crickit.drive_1
99
# For Feather Crickit, use:
10-
#drive_1 = crickit.feather_drive_1
10+
# drive_1 = crickit.feather_drive_1
1111

1212
# Turn on Drive 1 for 1 second and then off for 1 second
1313
while True:

0 commit comments

Comments
 (0)