Skip to content

Commit 409cb68

Browse files
authored
Merge pull request #60 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 5963200 + 5133a94 commit 409cb68

27 files changed

+362
-232
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_featherwing/alphanum_featherwing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import adafruit_ht16k33.segments as segments
3636
from adafruit_featherwing.led_segments import Segments
3737

38+
3839
class AlphaNumFeatherWing(Segments):
3940
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
4041
<https://www.adafruit.com/product/3139>`_.
4142
4243
Automatically uses the feather's I2C bus."""
44+
4345
def __init__(self, address=0x70, i2c=None):
4446
super().__init__()
4547
if i2c is None:

adafruit_featherwing/dotstar_featherwing.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import adafruit_dotstar as dotstar
3636
from adafruit_featherwing.pixelmatrix import PixelMatrix
3737

38+
3839
class DotStarFeatherWing(PixelMatrix):
3940
"""Class representing a `DotStar FeatherWing
4041
<https://www.adafruit.com/product/3449>`_.
4142
4243
The feather uses pins D13 and D11"""
44+
4345
def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
4446
"""
4547
:param pin clock: The clock pin for the featherwing
@@ -49,5 +51,10 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
4951
super().__init__()
5052
self.rows = 6
5153
self.columns = 12
52-
self._matrix = dotstar.DotStar(clock, data, self.rows * self.columns,
53-
brightness=brightness, auto_write=False)
54+
self._matrix = dotstar.DotStar(
55+
clock,
56+
data,
57+
self.rows * self.columns,
58+
brightness=brightness,
59+
auto_write=False,
60+
)

adafruit_featherwing/gps_featherwing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import busio
3636
import adafruit_gps
3737

38+
3839
class GPSFeatherWing:
3940
"""Class representing an `Ultimate GPS FeatherWing
4041
<https://www.adafruit.com/product/3133>`_.
4142
4243
Automatically uses the feather's UART bus."""
44+
4345
def __init__(self, update_period=1000, baudrate=9600):
4446
"""
4547
:param int update_period: (Optional) The amount of time in milliseconds between
@@ -57,8 +59,10 @@ def __init__(self, update_period=1000, baudrate=9600):
5759
self._uart = busio.UART(board.TX, board.RX, baudrate=baudrate, timeout=timeout)
5860
self._gps = adafruit_gps.GPS(self._uart, debug=False)
5961
# Turn on the basic GGA and RMC info
60-
self._gps.send_command(bytes('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'utf-8'))
61-
self._gps.send_command(bytes('PMTK220,{}'.format(update_period), 'utf-8'))
62+
self._gps.send_command(
63+
bytes("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", "utf-8")
64+
)
65+
self._gps.send_command(bytes("PMTK220,{}".format(update_period), "utf-8"))
6266

6367
def update(self):
6468
"""

adafruit_featherwing/ina219_featherwing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
import board
3535
import adafruit_ina219
3636

37+
3738
class INA219FeatherWing:
3839
"""Class representing an `Adafruit INA219 FeatherWing
3940
<https://www.adafruit.com/product/3650>`_.
4041
4142
Automatically uses the feather's I2C bus."""
43+
4244
def __init__(self, i2c=None):
4345
if i2c is None:
4446
i2c = board.I2C()

adafruit_featherwing/joy_featherwing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ class JoyFeatherWing:
4646
"""Class representing an `Adafruit Joy FeatherWing <https://www.adafruit.com/product/3632>`_.
4747
4848
Automatically uses the feather's I2C bus."""
49+
4950
def __init__(self, i2c=None):
5051
if i2c is None:
5152
i2c = board.I2C()
5253
self._seesaw = adafruit_seesaw.seesaw.Seesaw(i2c)
53-
self._seesaw.pin_mode_bulk(BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
54-
self._seesaw.INPUT_PULLUP)
54+
self._seesaw.pin_mode_bulk(
55+
BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
56+
self._seesaw.INPUT_PULLUP,
57+
)
5558

5659
# Initialise joystick_offset
5760
self._joystick_offset = (0, 0)

adafruit_featherwing/led_segments.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3333

34-
#pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
34+
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
35+
3536

3637
class Segments:
3738
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
3839
<https://www.adafruit.com/product/3139>`_.
3940
4041
Automatically uses the feather's I2C bus."""
42+
4143
def __init__(self):
4244
self._segments = None
4345

@@ -74,7 +76,7 @@ def fill(self, fill):
7476
self._segments.fill(1 if fill else 0)
7577
self._segments.show()
7678
else:
77-
raise ValueError('Must set to either True or False.')
79+
raise ValueError("Must set to either True or False.")
7880

7981
@property
8082
def blink_rate(self):

adafruit_featherwing/matrix_featherwing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import board
3636
import adafruit_ht16k33.matrix as matrix
3737

38+
3839
class MatrixFeatherWing:
3940
"""Class representing an `Adafruit 8x16 LED Matrix FeatherWing
4041
<https://www.adafruit.com/product/3155>`_.
4142
4243
Automatically uses the feather's I2C bus."""
44+
4345
def __init__(self, address=0x70, i2c=None):
4446
if i2c is None:
4547
i2c = board.I2C()
@@ -102,7 +104,7 @@ def fill(self, fill):
102104
self._matrix.fill(1 if fill else 0)
103105
self._update()
104106
else:
105-
raise ValueError('Must set to either True or False.')
107+
raise ValueError("Must set to either True or False.")
106108

107109
def shift_right(self, rotate=False):
108110
"""

adafruit_featherwing/minitft_featherwing.py

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,23 @@
5050

5151
Buttons = namedtuple("Buttons", "up down left right a b select")
5252

53+
5354
class MiniTFTFeatherWing:
5455
"""Class representing an `Mini Color TFT with Joystick FeatherWing
5556
<https://www.adafruit.com/product/3321>`_.
5657
5758
Automatically uses the feather's I2C bus."""
5859

59-
_button_mask = ((1 << BUTTON_RIGHT) |
60-
(1 << BUTTON_DOWN) |
61-
(1 << BUTTON_LEFT) |
62-
(1 << BUTTON_UP) |
63-
(1 << BUTTON_SEL) |
64-
(1 << BUTTON_A) |
65-
(1 << BUTTON_B))
66-
#pylint: disable-msg=too-many-arguments
60+
_button_mask = (
61+
(1 << BUTTON_RIGHT)
62+
| (1 << BUTTON_DOWN)
63+
| (1 << BUTTON_LEFT)
64+
| (1 << BUTTON_UP)
65+
| (1 << BUTTON_SEL)
66+
| (1 << BUTTON_A)
67+
| (1 << BUTTON_B)
68+
)
69+
# pylint: disable-msg=too-many-arguments
6770
def __init__(self, address=0x5E, i2c=None, spi=None, cs=None, dc=None):
6871
displayio.release_displays()
6972
if i2c is None:
@@ -81,9 +84,11 @@ def __init__(self, address=0x5E, i2c=None, spi=None, cs=None, dc=None):
8184
self._backlight = PWMOut(self._ss, 5)
8285
self._backlight.duty_cycle = 0
8386
display_bus = displayio.FourWire(spi, command=dc, chip_select=cs)
84-
self.display = ST7735R(display_bus, width=160, height=80, colstart=24,
85-
rotation=270, bgr=True)
86-
#pylint: enable-msg=too-many-arguments
87+
self.display = ST7735R(
88+
display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True
89+
)
90+
91+
# pylint: enable-msg=too-many-arguments
8792

8893
@property
8994
def backlight(self):
@@ -107,9 +112,31 @@ def buttons(self):
107112
try:
108113
button_values = self._ss.digital_read_bulk(self._button_mask)
109114
except OSError:
110-
return Buttons(*[False for button in
111-
(BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
112-
BUTTON_A, BUTTON_B, BUTTON_SEL)])
113-
return Buttons(*[not button_values & (1 << button) for button in
114-
(BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
115-
BUTTON_A, BUTTON_B, BUTTON_SEL)])
115+
return Buttons(
116+
*[
117+
False
118+
for button in (
119+
BUTTON_UP,
120+
BUTTON_DOWN,
121+
BUTTON_LEFT,
122+
BUTTON_RIGHT,
123+
BUTTON_A,
124+
BUTTON_B,
125+
BUTTON_SEL,
126+
)
127+
]
128+
)
129+
return Buttons(
130+
*[
131+
not button_values & (1 << button)
132+
for button in (
133+
BUTTON_UP,
134+
BUTTON_DOWN,
135+
BUTTON_LEFT,
136+
BUTTON_RIGHT,
137+
BUTTON_A,
138+
BUTTON_B,
139+
BUTTON_SEL,
140+
)
141+
]
142+
)

adafruit_featherwing/neopixel_featherwing.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
import neopixel
3636
from adafruit_featherwing.pixelmatrix import PixelMatrix
3737

38+
3839
class NeoPixelFeatherWing(PixelMatrix):
3940
"""Class representing a `NeoPixel FeatherWing
4041
<https://www.adafruit.com/product/2945>`_.
4142
4243
The feather uses pins D6 by default"""
44+
4345
def __init__(self, pixel_pin=board.D6, brightness=0.1):
4446
"""
4547
:param pin pixel_pin: The pin for the featherwing
@@ -48,9 +50,13 @@ def __init__(self, pixel_pin=board.D6, brightness=0.1):
4850
super().__init__()
4951
self.rows = 4
5052
self.columns = 8
51-
self._matrix = neopixel.NeoPixel(pixel_pin, self.rows * self.columns,
52-
brightness=brightness, auto_write=False,
53-
pixel_order=neopixel.GRB)
53+
self._matrix = neopixel.NeoPixel(
54+
pixel_pin,
55+
self.rows * self.columns,
56+
brightness=brightness,
57+
auto_write=False,
58+
pixel_order=neopixel.GRB,
59+
)
5460

5561
def shift_up(self, rotate=False):
5662
"""
@@ -83,7 +89,7 @@ def shift_up(self, rotate=False):
8389
time.sleep(.1)
8490
8591
"""
86-
super().shift_down(rotate) # Up and down are reversed
92+
super().shift_down(rotate) # Up and down are reversed
8793

8894
def shift_down(self, rotate=False):
8995
"""
@@ -116,4 +122,4 @@ def shift_down(self, rotate=False):
116122
time.sleep(.1)
117123
118124
"""
119-
super().shift_up(rotate) # Up and down are reversed
125+
super().shift_up(rotate) # Up and down are reversed

adafruit_featherwing/pixelmatrix.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232
__version__ = "0.0.0-auto.0"
3333
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3434

35-
#pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
35+
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
36+
3637

3738
class PixelMatrix:
3839
"""Base Class for DotStar and NeoPixel FeatherWings
3940
4041
The feather uses pins D13 and D11"""
42+
4143
def __init__(self):
4244
self.rows = 0
4345
self.columns = 0
@@ -74,18 +76,18 @@ def _get_index(self, indices):
7476
"""
7577
if isinstance(indices, int):
7678
if not 0 <= indices < self.rows * self.columns:
77-
raise ValueError('The index of {} is out of range'.format(indices))
79+
raise ValueError("The index of {} is out of range".format(indices))
7880
return indices
7981
if isinstance(indices, slice):
8082
return indices
8183
if len(indices) == 2:
8284
x, y = indices
8385
if not 0 <= x < self.columns:
84-
raise ValueError('The X value of {} is out of range'.format(x))
86+
raise ValueError("The X value of {} is out of range".format(x))
8587
if not 0 <= y < self.rows:
86-
raise ValueError('The Y value of {} is out of range'.format(y))
88+
raise ValueError("The Y value of {} is out of range".format(y))
8789
return y * self.columns + x
88-
raise ValueError('Index must be 1 or 2 number')
90+
raise ValueError("Index must be 1 or 2 number")
8991

9092
def _update(self):
9193
"""
@@ -120,7 +122,9 @@ def shift_right(self, rotate=False):
120122
for y in range(0, self.rows):
121123
last_pixel = self._matrix[(y + 1) * self.columns - 1] if rotate else 0
122124
for x in range(self.columns - 1, 0, -1):
123-
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x - 1]
125+
self._matrix[y * self.columns + x] = self._matrix[
126+
y * self.columns + x - 1
127+
]
124128
self._matrix[y * self.columns] = last_pixel
125129
self._update()
126130

@@ -133,7 +137,9 @@ def shift_left(self, rotate=False):
133137
for y in range(0, self.rows):
134138
last_pixel = self._matrix[y * self.columns] if rotate else 0
135139
for x in range(0, self.columns - 1):
136-
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x + 1]
140+
self._matrix[y * self.columns + x] = self._matrix[
141+
y * self.columns + x + 1
142+
]
137143
self._matrix[(y + 1) * self.columns - 1] = last_pixel
138144
self._update()
139145

@@ -144,9 +150,13 @@ def shift_up(self, rotate=False):
144150
:param rotate: (Optional) Rotate the shifted pixels to bottom (default=False)
145151
"""
146152
for x in range(0, self.columns):
147-
last_pixel = self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
153+
last_pixel = (
154+
self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
155+
)
148156
for y in range(self.rows - 1, 0, -1):
149-
self._matrix[y * self.columns + x] = self._matrix[(y - 1) * self.columns + x]
157+
self._matrix[y * self.columns + x] = self._matrix[
158+
(y - 1) * self.columns + x
159+
]
150160
self._matrix[x] = last_pixel
151161
self._update()
152162

@@ -159,7 +169,9 @@ def shift_down(self, rotate=False):
159169
for x in range(0, self.columns):
160170
last_pixel = self._matrix[x] if rotate else 0
161171
for y in range(0, self.rows - 1):
162-
self._matrix[y * self.columns + x] = self._matrix[(y + 1) * self.columns + x]
172+
self._matrix[y * self.columns + x] = self._matrix[
173+
(y + 1) * self.columns + x
174+
]
163175
self._matrix[(self.rows - 1) * self.columns + x] = last_pixel
164176
self._update()
165177

0 commit comments

Comments
 (0)