3636values = [True ] # [True, False]
3737
3838def 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
4142def 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
4852if 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
5357ios = ios_lookup .values ()
5458ios_items = ios_lookup .items ()
5559for 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
6064class 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