What changed, and why it matters
This commit is a minor code cleanup in a Python helper script. It moves existing bootloader connection logic into a small nested helper function to satisfy a style checker (pylint's limit on the number of return statements). No behavior changes, no security fixes, and no new functionality were introduced.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In py/send_message.py, the USB bootloader fallback logic inside connect_to_usb_bitbox() was extracted into a nested function connect_to_bootloader(). The original try/except for finding a BitBox02 device remains, but the NoneFoundException branch now calls the new helper. The diff shows only code motion: identical exception handling, identical print statements, identical object construction, and identical return values. The change is purely structural to reduce the number of return statements in the enclosing function.
Changed components
py/send_message.pyInspect captured patch +10 / −6
diff --git a/py/send_message.py b/py/send_message.py
index ef07354..d090e53 100755
--- a/py/send_message.py
+++ b/py/send_message.py
@@ -1994,12 +1994,8 @@ def connect_to_usb_bitbox(debug: bool, use_cache: bool) -> int:
Connects and runs the main menu on a BitBox02 connected
over USB.
"""
- try:
- bitbox = devices.get_any_bitbox02()
- except devices.TooManyFoundException:
- print("Multiple bitboxes detected. Only one supported")
- return 1
- except devices.NoneFoundException:
+
+ def connect_to_bootloader() -> int:
try:
bootloader = devices.get_any_bitbox02_bootloader()
except devices.TooManyFoundException:
@@ -2020,6 +2016,14 @@ def connect_to_usb_bitbox(debug: bool, use_cache: bool) -> int:
boot_app = SendMessageBootloader(bootloader_connection)
return boot_app.run()
+ try:
+ bitbox = devices.get_any_bitbox02()
+ except devices.TooManyFoundException:
+ print("Multiple bitboxes detected. Only one supported")
+ return 1
+ except devices.NoneFoundException:
+ return connect_to_bootloader()
+
def show_pairing(code: str, device_response: Callable[[], bool]) -> bool:
print("Please compare and confirm the pairing code on your BitBox02:")
print(code)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.