Skip to content

Commit f0e9c3a

Browse files
committed
Fix pylint diagnostics
1 parent b02b572 commit f0e9c3a

File tree

1 file changed

+20
-12
lines changed
  • CircuitPython_Commodore_16_KB2040/matrixwhisperer

1 file changed

+20
-12
lines changed

CircuitPython_Commodore_16_KB2040/matrixwhisperer/code.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,34 @@
3636
values = [True] # [True, False]
3737

3838
def discover_io():
39-
return [pin_maybe for name in dir(microcontroller.pin) if isinstance(pin_maybe := getattr(microcontroller.pin, name), microcontroller.Pin)]
39+
return [pin_maybe for name in dir(microcontroller.pin)
40+
if isinstance(pin_maybe := getattr(microcontroller.pin, name), microcontroller.Pin)]
4041

4142
def pin_lookup(pin):
4243
for i in dir(board):
43-
if getattr(board, i) is pin: return i
44+
if getattr(board, i) is pin:
45+
return i
4446
for i in dir(microcontroller.pin):
45-
if getattr(microcontroller.pin, i) is pin: return i
47+
if getattr(microcontroller.pin, i) is pin:
48+
return i
49+
return str(pin)
4650

4751
# Find all I/O pins, if IO_PINS is not explicitly set above
4852
if IO_PINS is None:
4953
IO_PINS = discover_io()
5054

5155
# Initialize all pins as inputs, make a lookup table to get the name from the pin
52-
ios_lookup = dict([(pin_lookup(pin), DigitalInOut(pin)) for pin in IO_PINS])
56+
ios_lookup = dict([(pin_lookup(pin), DigitalInOut(pin)) for pin in IO_PINS]) # pylint: disable=consider-using-dict-comprehension
5357
ios = ios_lookup.values()
5458
ios_items = ios_lookup.items()
5559
for io in ios:
5660
io.switch_to_input(pull=Pull.UP)
5761

58-
# Partial implementation of 'defaultdict' class from standard Python
59-
# from https://github.com/micropython/micropython-lib/blob/master/python-stdlib/collections.defaultdict/collections/defaultdict.py
62+
# Partial implementation of 'defaultdict' class from standard Python from
63+
# https://github.com/micropython/micropython-lib/blob/master/python-stdlib/collections.defaultdict/collections/defaultdict.py
6064
class defaultdict:
6165
@staticmethod
62-
def __new__(cls, default_factory=None, **kwargs):
66+
def __new__(cls, default_factory=None, **kwargs): # pylint: disable=unused-argument
6367
# Some code (e.g. urllib.urlparse) expects that basic defaultdict
6468
# functionality will be available to subclasses without them
6569
# calling __init__().
@@ -115,13 +119,15 @@ def __missing__(self, key):
115119
for name1, io1 in ios_items:
116120
io1.switch_to_output(value)
117121
for name2, io2 in ios_items:
118-
if io2 is io1: continue
122+
if io2 is io1:
123+
continue
119124
if io2.value == value:
120125
if first_run:
121126
pressed_or_junk[name1].add(name2)
122127
pressed_or_junk[name2].add(name1)
123128
elif name2 not in pressed_or_junk[name1]:
124-
if row_arbitrarily is None: row_arbitrarily = name1
129+
if row_arbitrarily is None:
130+
row_arbitrarily = name1
125131
pressed_or_junk[name1].add(name2)
126132
pressed_or_junk[name2].add(name1)
127133
if name2 not in pressed[name1]:
@@ -131,7 +137,8 @@ def __missing__(self, key):
131137
if name2 in pressed[name1]:
132138
last_pressed = (name1, name2)
133139
print("Key registered. Release to continue")
134-
while io2.value == value: pass
140+
while io2.value == value:
141+
pass
135142
io1.switch_to_input(pull=pull)
136143
if first_run:
137144
print("Press keys now")
@@ -142,12 +149,13 @@ def __missing__(self, key):
142149
to_check = [row_arbitrarily]
143150
for check in to_check:
144151
for other in pressed[check]:
145-
if other in rows or other in cols: continue
152+
if other in rows or other in cols:
153+
continue
146154
if check in rows:
147155
cols.add(other)
148156
else:
149157
rows.add(other)
150-
to_check.append(other)
158+
to_check.append(other) # pylint: disable=modified-iterating-list
151159

152160
rows = sorted(rows)
153161
cols = sorted(cols)

0 commit comments

Comments
 (0)