Skip to content

Commit 66f2b5b

Browse files
authored
Merge pull request #10 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents cdb3cb2 + d0e416d commit 66f2b5b

File tree

7 files changed

+111
-95
lines changed

7 files changed

+111
-95
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_rgbled.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
__version__ = "0.0.0-auto.0"
4444
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGBLED.git"
4545

46+
4647
class RGBLED:
4748
"""
4849
Creates a RGBLED object given three physical pins or PWMOut objects.
@@ -111,16 +112,17 @@ class RGBLED:
111112
rgb_led.color = (0, 255, 0)
112113
113114
"""
115+
114116
def __init__(self, red_pin, green_pin, blue_pin, invert_pwm=False):
115117
self._rgb_led_pins = [red_pin, green_pin, blue_pin]
116118
for i in range(len(self._rgb_led_pins)):
117-
if hasattr(self._rgb_led_pins[i], 'frequency'):
119+
if hasattr(self._rgb_led_pins[i], "frequency"):
118120
self._rgb_led_pins[i].duty_cycle = 0
119121
elif str(type(self._rgb_led_pins[i])) == "<class 'Pin'>":
120122
self._rgb_led_pins[i] = PWMOut(self._rgb_led_pins[i])
121123
self._rgb_led_pins[i].duty_cycle = 0
122124
else:
123-
raise TypeError('Must provide a pin, PWMOut, or PWMChannel.')
125+
raise TypeError("Must provide a pin, PWMOut, or PWMChannel.")
124126
self._invert_pwm = invert_pwm
125127
self._current_color = (0, 0, 0)
126128
self.color = self._current_color
@@ -134,7 +136,7 @@ def __exit__(self, exception_type, exception_value, traceback):
134136
def deinit(self):
135137
"""Turn the LEDs off, deinit pwmout and release hardware resources."""
136138
for pin in self._rgb_led_pins:
137-
pin.deinit() #pylint: no-member
139+
pin.deinit() # pylint: no-member
138140
self._current_color = (0, 0, 0)
139141

140142
@property
@@ -155,16 +157,16 @@ def color(self, value):
155157
color -= 65535
156158
self._rgb_led_pins[i].duty_cycle = abs(color)
157159
elif isinstance(value, int):
158-
if value>>24:
160+
if value >> 24:
159161
raise ValueError("Only bits 0->23 valid for integer input")
160162
r = value >> 16
161-
g = (value >> 8) & 0xff
162-
b = value & 0xff
163+
g = (value >> 8) & 0xFF
164+
b = value & 0xFF
163165
rgb = [r, g, b]
164166
for color in range(0, 3):
165167
rgb[color] = int(map_range(rgb[color], 0, 255, 0, 65535))
166168
if self._invert_pwm:
167169
rgb[color] -= 65535
168170
self._rgb_led_pins[color].duty_cycle = abs(rgb[color])
169171
else:
170-
raise ValueError('Color must be a tuple or 24-bit integer value.')
172+
raise ValueError("Color must be a tuple or 24-bit integer value.")

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 = ["pulseio"]
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 RGBLED Library'
38-
copyright = u'2019 Brent Rubell'
39-
author = u'Brent Rubell'
41+
project = "Adafruit RGBLED Library"
42+
copyright = "2019 Brent Rubell"
43+
author = "Brent Rubell"
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 = "1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = "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 = 'AdafruitRgbledLibrarydoc'
117+
htmlhelp_basename = "AdafruitRgbledLibrarydoc"
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, 'AdafruitRGBLEDLibrary.tex', u'AdafruitRGBLED Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitRGBLEDLibrary.tex",
143+
"AdafruitRGBLED 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, 'AdafruitRGBLEDlibrary', u'Adafruit RGBLED Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitRGBLEDlibrary",
157+
"Adafruit RGBLED 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, 'AdafruitRGBLEDLibrary', u'Adafruit RGBLED Library Documentation',
158-
author, 'AdafruitRGBLEDLibrary', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitRGBLEDLibrary",
172+
"Adafruit RGBLED Library Documentation",
173+
author,
174+
"AdafruitRGBLEDLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/rgbled_blink.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import adafruit_rgbled
66

77
# Configure the setup
8-
RED_LED = board.D5 # Pin the Red LED is connected to
9-
GREEN_LED = board.D6 # Pin the Green LED is connected to
10-
BLUE_LED = board.D7 # Pin the Blue LED is connected to
8+
RED_LED = board.D5 # Pin the Red LED is connected to
9+
GREEN_LED = board.D6 # Pin the Green LED is connected to
10+
BLUE_LED = board.D7 # Pin the Blue LED is connected to
1111
COLOR = (100, 50, 150) # color to blink
12-
CLEAR = (0, 0, 0) # clear (or second color)
13-
DELAY = 0.25 # blink rate in seconds
12+
CLEAR = (0, 0, 0) # clear (or second color)
13+
DELAY = 0.25 # blink rate in seconds
1414

1515
# Create the RGB LED object
1616
led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED)

examples/rgbled_pca9685.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# PCA9685 Initialization
88
i2c = busio.I2C(board.SCL, board.SDA)
99
pca = adafruit_pca9685.PCA9685(i2c)
10-
pca.frequency=60
10+
pca.frequency = 60
1111

1212
# PCA9685 LED Channels
1313
RED_LED = pca.channels[0]
@@ -20,6 +20,7 @@
2020
# Optionally, you can also create the RGB LED object with inverted PWM
2121
# led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED, invert_pwm=True)
2222

23+
2324
def wheel(pos):
2425
# Input a value 0 to 255 to get a color value.
2526
# The colours are a transition r - g - b - back to r.
@@ -33,23 +34,25 @@ def wheel(pos):
3334
pos -= 170
3435
return int(pos * 3), 0, int(255 - (pos * 3))
3536

37+
3638
def rainbow_cycle(wait):
3739
for i in range(255):
3840
i = (i + 1) % 256
3941
led.color = wheel(i)
4042
time.sleep(wait)
4143

44+
4245
while True:
4346
# setting RGB LED color to RGB Tuples (R, G, B)
44-
print('setting color 1')
47+
print("setting color 1")
4548
led.color = (255, 0, 0)
4649
time.sleep(1)
4750

48-
print('setting color 2')
51+
print("setting color 2")
4952
led.color = (0, 255, 0)
5053
time.sleep(1)
5154

52-
print('setting color 3')
55+
print("setting color 3")
5356
led.color = (0, 0, 255)
5457
time.sleep(1)
5558

examples/rgbled_simpletest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Optionally, you can also create the RGB LED object with inverted PWM
1818
# led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED, invert_pwm=True)
1919

20+
2021
def wheel(pos):
2122
# Input a value 0 to 255 to get a color value.
2223
# The colours are a transition r - g - b - back to r.
@@ -30,12 +31,14 @@ def wheel(pos):
3031
pos -= 170
3132
return int(pos * 3), 0, int(255 - (pos * 3))
3233

34+
3335
def rainbow_cycle(wait):
3436
for i in range(255):
3537
i = (i + 1) % 256
3638
led.color = wheel(i)
3739
time.sleep(wait)
3840

41+
3942
while True:
4043
# setting RGB LED color to RGB Tuples (R, G, B)
4144
led.color = (255, 0, 0)

0 commit comments

Comments
 (0)