1+ # SPDX-FileCopyrightText: 2025 John Park and Claude AI for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
14"""
25# input_handler.py: CircuitPython Music Staff Application component
36"""
1114
1215
1316# pylint: disable=invalid-name,no-member,too-many-instance-attributes,too-many-arguments
14- # pylint: disable=too-many-branches,too-many-statements,broad-exception-caught
15- # pylint: disable=too-many-nested-blocks,too-many-locals,too-many-positional-arguments
17+ # pylint: disable=too-many-branches,too-many-statements,broad-except
18+ # pylint: disable=too-many-nested-blocks,too-many-locals,no-self-use
1619class InputHandler :
1720 """Handles user input through mouse and interactions with UI elements"""
1821
@@ -62,7 +65,7 @@ def find_mouse(self):
6265 try :
6366 manufacturer = device .manufacturer
6467 product = device .product
65- except Exception : # Specify exception type
68+ except Exception : # pylint: disable=broad-except
6669 manufacturer = "Unknown"
6770 product = "Unknown"
6871
@@ -74,13 +77,13 @@ def find_mouse(self):
7477 has_kernel_driver = hasattr (device , 'is_kernel_driver_active' )
7578 if has_kernel_driver and device .is_kernel_driver_active (0 ):
7679 device .detach_kernel_driver (0 )
77- except Exception as e :
80+ except Exception as e : # pylint: disable=broad-except
7881 print (f"Error detaching kernel driver: { e } " )
7982
8083 # Set configuration
8184 try :
8285 device .set_configuration ()
83- except Exception as e :
86+ except Exception as e : # pylint: disable=broad-except
8487 print (f"Error setting configuration: { e } " )
8588 continue # Try next device
8689
@@ -98,7 +101,7 @@ def find_mouse(self):
98101 buf = bytearray (1 )
99102 device .ctrl_transfer (bmRequestType , bRequest , wValue , wIndex , buf )
100103 print ("Set to report protocol mode" )
101- except Exception as e :
104+ except Exception as e : # pylint: disable=broad-except
102105 print (f"Could not set protocol: { e } " )
103106
104107 # Buffer for reading data
@@ -115,14 +118,14 @@ def find_mouse(self):
115118 # Timeout is normal if mouse isn't moving
116119 print ("Mouse connected but not sending data (normal)" )
117120 return True
118- except Exception as e :
121+ except Exception as e : # pylint: disable=broad-except
119122 print (f"Mouse test read failed: { e } " )
120123 # Continue to try next device or retry
121124 self .mouse = None
122125 self .in_endpoint = None
123126 continue
124127
125- except Exception as e :
128+ except Exception as e : # pylint: disable=broad-except
126129 print (f"Error initializing device: { e } " )
127130 continue
128131
@@ -134,7 +137,7 @@ def find_mouse(self):
134137 gc .collect ()
135138 time .sleep (RETRY_DELAY )
136139
137- except Exception as e :
140+ except Exception as e : # pylint: disable=broad-except
138141 print (f"Error during mouse detection: { e } " )
139142 gc .collect ()
140143 time .sleep (RETRY_DELAY )
@@ -204,7 +207,7 @@ def process_mouse_input(self):
204207 gc .collect ()
205208
206209 return False
207- except Exception as e :
210+ except Exception as e : # pylint: disable=broad-except
208211 print (f"Error reading mouse: { type (e ).__name__ } " )
209212 return False
210213
0 commit comments