Skip to content

Fix #443: narrow bare except and remove dead code in inputs.py - #473

Open
prawnsgupta wants to merge 1 commit into
JdeRobot:masterfrom
prawnsgupta:fix/443-inputs-cleanup
Open

Fix #443: narrow bare except and remove dead code in inputs.py#473
prawnsgupta wants to merge 1 commit into
JdeRobot:masterfrom
prawnsgupta:fix/443-inputs-cleanup

Conversation

@prawnsgupta

@prawnsgupta prawnsgupta commented Jul 17, 2026

Copy link
Copy Markdown

Fixes #443 @jmplaza @BkPankaj

Changes in backend/staticfiles/synthesis/lib/inputs.py

  1. Narrowed the bare except: in create_number_wire() to except FileNotFoundError:. A bare except also swallows KeyboardInterrupt/SystemExit and can hide real bugs; FileNotFoundError is the specific exception SharedMemory(name=...) raises when the block doesn't exist yet, and matches how create_readonly_wire() already handles it. Also normalized the function's indentation to 4 spaces.
  2. Removed the unused _init_enabled() method. Its own comment marked it redundant, a repo-wide grep finds no callers, and it references a non-existent self.enable_wire attribute, so it would raise AttributeError if ever called.
  3. Removed the now-unused Condition import (it was only referenced by the deleted method) and a leftover commented-out line (# self.shms.append(shm)), which referenced self inside a plain function.
  4. Converted the resolved TODO in the enabled setter into a normal explanatory comment, per the issue.

Verification

  • python -m py_compile backend/staticfiles/synthesis/lib/inputs.py passes
  • grep -rn "_init_enabled" across the repo returns no remaining references

Diff: 1 file, +9/−17.

image image

- Replace bare 'except:' in create_number_wire() with
  'except FileNotFoundError:' (matches create_readonly_wire) and fix
  its indentation to 4 spaces
- Remove unused _init_enabled() (self-documented as redundant; no
  callers found repo-wide) and the now-unused Condition import
- Remove leftover commented-out line and convert the resolved TODO in
  the enabled setter into a normal explanatory comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve exception handling and remove dead code in inputs.py

1 participant