Skip to content

fix: replace bare except clauses with except Exception#463

Open
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:optimize/fix-bare-except-clauses
Open

fix: replace bare except clauses with except Exception#463
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:optimize/fix-bare-except-clauses

Conversation

@Kailigithub
Copy link
Copy Markdown
Contributor

Replace 44 bare except: statements with except Exception: across 14 source files.

Bare except: clauses catch all exceptions including SystemExit and KeyboardInterrupt, which should normally propagate. This is a standard Python best practice (PEP 8 / E722) fix.

Changes:

  • llmcore.py — 16 occurrences (SSE parsing, JSON decode, retry logic)
  • ga.py — 8 occurrences (code execution, file I/O, verbose print)
  • simphtml.py — 4 occurrences (DOM monitoring, page diff)
  • agentmain.py — 3 occurrences (session init, LLM client switch)
  • frontends/qtapp.py — 2 occurrences (message rendering)
  • frontends/stapp.py — 2 occurrences (stdout/stderr reconfigure)
  • frontends/stapp2.py — 2 occurrences (stdout/stderr reconfigure)
  • Plus 5 other files with 1 occurrence each

Verification:

  • All 57 Python files pass python3 -m py_compile syntax check
  • ruff check --select E722 shows 0 remaining violations
  • No behavioral change — Exception catches the same errors as bare except in all these cases

Replace 44 bare  statements across 14 files with .
Bare except clauses catch SystemExit and KeyboardInterrupt which should
propagate normally. This is a safe drop-in replacement that preserves
existing error handling behavior while fixing the E722 lint violations.
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.

1 participant