Skip to content

fix(cli): move return out of finally block in _voice_stop_and_transcribe (Python 3.14+)#21261

Open
wali-reheman wants to merge 1 commit into
NousResearch:mainfrom
wali-reheman:fix/voice-finally-syntaxwarning-python314
Open

fix(cli): move return out of finally block in _voice_stop_and_transcribe (Python 3.14+)#21261
wali-reheman wants to merge 1 commit into
NousResearch:mainfrom
wali-reheman:fix/voice-finally-syntaxwarning-python314

Conversation

@wali-reheman

Copy link
Copy Markdown
Contributor

Summary

Fixes Python 3.14 in caused by a statement inside a block.

Problem

Python 3.14 emits when a appears inside a block, because suppresses any exception that was propagating through the clause. This is a known Python anti-pattern since 3.8.

The method had the following structure:

Fix

Move the business logic outside the block. Only the cleanup actions remain in :

  • Release
  • Invalidate
  • Remove temp wav file

The following logic is now outside (at module level of the method, dedented by one level):

  • Track consecutive no-speech cycles
  • Stop continuous mode after 3 no-speech events
  • Restart recording in continuous mode when no transcript submitted

Changes

  • : — 1 net line change (exact same line count, restructured indentation). All 12-space-indented content stays in ; the 16-space-indented business logic moves to module level.

Testing

Python 3.14's flag will confirm the fix.

Related Issue

Closes #21088

Fixes SyntaxWarning on Python 3.14+ where a return statement inside
a finally block suppresses any propagating exception.

The business logic (track no-speech cycles, restart recording in
continuous mode) is moved outside the finally block. Only the
cleanup actions (release _voice_lock, invalidate app, remove temp
wav file) remain in finally — all of which are safe to run even
when an exception is propagating.
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists labels May 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #21100 (same fix: remove return-in-finally in _voice_stop_and_transcribe for Python 3.14+ SyntaxWarning). Both implement #21088.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SyntaxWarning: return in finally block in _voice_process_recording (Python 3.14+)

2 participants