Skip to content

Commit ab4244d

Browse files
committed
remove type: ignore and minor refactor for dir/hasattr adafruit#18
1 parent 4fe2546 commit ab4244d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_bitmapsaver.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ def _write_pixels(
9595
if saving_bitmap:
9696
# pixel_source: Bitmap
9797
for x in range(width):
98-
pixel = pixel_source[x, y - 1] # type: ignore
99-
color = palette[pixel] # type: ignore # handled by save_pixel's guardians
98+
pixel = pixel_source[x, y - 1]
99+
color = palette[pixel] # handled by save_pixel's guardians
100100
for _ in range(3):
101101
row_buffer[buffer_index] = color & 0xFF
102102
color >>= 8
103103
buffer_index += 1
104104
else:
105105
# pixel_source: Display
106106
result_buffer = bytearray(2048)
107-
data = pixel_source.fill_row(y - 1, result_buffer) # type: ignore
107+
data = pixel_source.fill_row(y - 1, result_buffer)
108108
for i in range(width):
109109
pixel565 = (data[i * 2] << 8) + data[i * 2 + 1]
110110
for b in _rgb565_to_bgr_tuple(pixel565):
@@ -133,7 +133,7 @@ def save_pixels(
133133
:param palette: the Palette to use for looking up colors in the bitmap
134134
"""
135135
if not pixel_source:
136-
if "DISPLAY" not in dir(board):
136+
if not hasattr(board, 'DISPLAY'):
137137
raise ValueError("Second argument must be a Bitmap or Display")
138138
pixel_source = board.DISPLAY
139139

0 commit comments

Comments
 (0)