Skip to content

Commit ae22f03

Browse files
committed
Linted
1 parent 458882b commit ae22f03

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

adafruit_framebuf.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def fill(framebuf, color):
6464
fill = 0xFF
6565
else:
6666
fill = 0x00
67-
for i in range(len(framebuf.buf)):
67+
for i in range(len(framebuf.buf)): # pylint: disable=consider-using-enumerate
6868
framebuf.buf[i] = fill
6969

7070
@staticmethod
@@ -107,7 +107,7 @@ def fill(framebuf, color):
107107
fill = 0xFF
108108
else:
109109
fill = 0x00
110-
for i in range(len(framebuf.buf)):
110+
for i in range(len(framebuf.buf)): # pylint: disable=consider-using-enumerate
111111
framebuf.buf[i] = fill
112112

113113
@staticmethod
@@ -388,7 +388,7 @@ def text(self, string, x, y, color, *, font_name="font5x8.bin", size=1):
388388
# determine our effective width/height, taking rotation into account
389389
frame_width = self.width
390390
frame_height = self.height
391-
if self.rotation == 1 or self.rotation == 3:
391+
if self.rotation in (1, 3):
392392
frame_width, frame_height = frame_height, frame_width
393393

394394
for chunk in string.split("\n"):
@@ -416,7 +416,7 @@ def image(self, img):
416416
# determine our effective width/height, taking rotation into account
417417
width = self.width
418418
height = self.height
419-
if self.rotation == 1 or self.rotation == 3:
419+
if self.rotation in (1, 3):
420420
width, height = height, width
421421

422422
if isinstance(self.format, RGB888Format) and img.mode != "RGB":
@@ -434,7 +434,7 @@ def image(self, img):
434434
# Grab all the pixels from the image, faster than getpixel.
435435
pixels = img.load()
436436
# Clear buffer
437-
for i in range(len(self.buf)):
437+
for i in range(len(self.buf)): # pylint: disable=consider-using-enumerate
438438
self.buf[i] = 0
439439
# Iterate through the pixels
440440
for x in range(width): # yes this double loop is slow,
@@ -469,7 +469,9 @@ def __init__(self, font_name="font5x8.bin"):
469469
# Open the font file and grab the character width and height values.
470470
# Note that only fonts up to 8 pixels tall are currently supported.
471471
try:
472-
self._font = open(self.font_name, "rb")
472+
self._font = open( # pylint: disable=consider-using-with
473+
self.font_name, "rb"
474+
)
473475
self.font_width, self.font_height = struct.unpack("BB", self._font.read(2))
474476
# simple font file validation check based on expected file size
475477
if 2 + 256 * self.font_width != os.stat(font_name)[6]:

0 commit comments

Comments
 (0)