Skip to content

Commit 3232d28

Browse files
committed
Cleaning up pylint errors
1 parent b756b5e commit 3232d28

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

adafruit_is31fl3731/__init__.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class IS31FL3731:
104104
width: int = 16
105105
height: int = 9
106106

107-
def __init__(self, i2c: busio.I2C, address: int = 0x74, frames: int = None) -> None:
107+
def __init__(self, i2c: None, address: int = 0x74, frames: int = None) -> None:
108108
self.i2c_device = I2CDevice(i2c, address)
109109
self._frame = None
110110
self._init(frames=frames)
@@ -325,7 +325,7 @@ def pixel_addr(x, y):
325325
"""Calulate the offset into the device array for x,y pixel"""
326326
return x + y * 16
327327

328-
# pylint: disable-msg=too-many-arguments
328+
# pylint: disable-msg=too-many-arguments, too-many-branches
329329
def pixel(
330330
self,
331331
x: int,
@@ -350,27 +350,27 @@ def pixel(
350350
raise ValueError("Rotation must be 0, 90, 180, or 270 degrees")
351351

352352
if rotate == 0:
353-
if not 0 <= x <= self.width:
354-
return None
355-
if not 0 <= y <= self.height:
353+
check_x = 0 <= x <= self.width
354+
check_y = 0 <= y <= self.height
355+
if not (check_x and check_y):
356356
return None
357357
pixel = self.pixel_addr(x, y)
358358
elif rotate == 90:
359-
if not 0 <= y <= self.width:
360-
return None
361-
if not 0 <= x <= self.height:
359+
check_x = 0 <= y <= self.width
360+
check_y = 0 <= x <= self.height
361+
if not (check_x and check_y):
362362
return None
363363
pixel = self.pixel_addr(y, self.height - x - 1)
364364
elif rotate == 180:
365-
if not 0 <= x <= self.width:
366-
return None
367-
if not 0 <= y <= self.height:
365+
check_x = 0 <= x <= self.width
366+
check_y = 0 <= y <= self.height
367+
if not (check_x and check_y):
368368
return None
369369
pixel = self.pixel_addr(self.width - x - 1, self.height - y - 1)
370370
elif rotate == 270:
371-
if not 0 <= y <= self.width:
372-
return None
373-
if not 0 <= x <= self.height:
371+
check_x = 0 <= y <= self.width
372+
check_y = 0 <= x <= self.height
373+
if not (check_x and check_y):
374374
return None
375375
pixel = self.pixel_addr(self.width - y - 1, x)
376376

@@ -410,9 +410,7 @@ def image(self, img: bytes = None, blink: bool = False, frame: int = 0) -> bytes
410410
imwidth, imheight = img.size
411411
if imwidth != self.width or imheight != self.height:
412412
raise ValueError(
413-
"Image must be same dimensions as display ({0}x{1}).".format(
414-
self.width, self.height
415-
)
413+
f"Image must be same dimensions as display {self.width}x{self.height}"
416414
)
417415
# Grab all the pixels from the image, faster than getpixel.
418416
pixels = img.load()

adafruit_is31fl3731/matrix.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from . import IS31FL3731
3131

3232
try:
33-
from typing import TYPE_CHECKING, List, Tuple
33+
from typing import TYPE_CHECKING
3434

3535
if TYPE_CHECKING:
3636
from circuitpython_typing import ReadableBuffer
@@ -69,13 +69,11 @@ def image(self, img: str = None, blink: bool = False, frame: int = 0):
6969
raise ValueError("Image must be in mode L.")
7070
if img.size[0] != self.width or img.size[1] != self.height:
7171
raise ValueError(
72-
"Image must be same dimensions as display ({0}x{1}).".format(
73-
self.width, self.height
74-
)
72+
f"Image must be same dimensions as display {self.width}x{self.height}"
7573
)
7674

7775
# Frame-select and then write pixel data in one big operation
78-
if frame is not 0:
76+
if frame != 0:
7977
self._bank(frame)
8078
# We can safely reduce the image to a "flat" byte sequence because
8179
# the matrix layout is known linear; no need to go through a 2D
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2024 DJDevon3
22
# SPDX-License-Identifier: MIT
33
""" Adafruit 16x9 Charlieplexed PWM LED Matrix Example """
4-
4+
# pylint: disable=import-error
55
import board
66
import adafruit_framebuf
77

@@ -14,28 +14,28 @@
1414
i2c = board.STEMMA_I2C()
1515
display = Display(i2c, address=0x74)
1616

17-
pixel_rotation = 90 # display rotation (0,90,180,270)
18-
pixel_brightness = 20 # values (0-255)
19-
pixel_blink = False # blink entire display
17+
PIXEL_ROTATION = 0 # display rotation (0,90,180,270)
18+
PIXEL_BRIGHTNESS = 20 # values (0-255)
19+
PIXEL_BLINK = False # blink entire display
2020

21-
text_to_show = "Hello World!" # Scrolling marquee text
21+
TEXT = "Hello World!" # Scrolling marquee text
2222

2323
print(f"Display Dimensions: {display.width}x{display.height}")
24-
print(f"Text: {text_to_show}")
24+
print(f"Text: {TEXT}")
2525

2626
# Create a framebuffer for our display
2727
buf = bytearray(32) # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes)
2828
buffer = adafruit_framebuf.FrameBuffer(
2929
buf, display.width, display.height, adafruit_framebuf.MVLSB
3030
)
3131

32-
frame = 0 # start with frame 0
32+
FRAME = 0 # start with frame 0
3333
while True:
3434
# Looping marquee
35-
for i in range(len(text_to_show) * 9):
35+
for i in range(len(TEXT) * 9):
3636
buffer.fill(0)
37-
buffer.text(text_to_show, -i + display.width, 0, color=1)
38-
display.frame(frame, show=False)
37+
buffer.text(TEXT, -i + display.width, 0, color=1)
38+
display.frame(FRAME, show=False)
3939
display.fill(0)
4040
for x in range(display.width):
4141
# using the FrameBuffer text result
@@ -45,5 +45,5 @@
4545
# if bit > 0 then set the pixel brightness
4646
if bit:
4747
display.pixel(
48-
x, y, pixel_brightness, blink=pixel_blink, rotate=pixel_rotation
48+
x, y, PIXEL_BRIGHTNESS, blink=PIXEL_BLINK, rotate=PIXEL_ROTATION
4949
)

0 commit comments

Comments
 (0)