Skip to content

refactor: extract _save_config_safely helper in TTS window - #61

Merged
TimInTech merged 1 commit into
mainfrom
refactor/tts-save-config-helper
Sep 18, 2026
Merged

TimInTech merged 1 commit into
mainfrom
refactor/tts-save-config-helper

Conversation

@TimInTech

Copy link
Copy Markdown
Owner

What changed?

Adds a module-level _save_config_safely(config) helper in app/tts_window.py (next to _safe_unlink()) and replaces six identical try: config.save() / except Exception: pass blocks with it: _ensure_openai_consent, _revert_provider_to_piper, _on_provider_changed, _on_voice_changed (2x), _on_model_changed. One file, +14/-24, no behavior change.

_on_speed_changed is intentionally left as is: its try also covers the tts_speed property setter (float(value)), which can raise.

Why?

Removes duplicated silent error handling from a cleanup audit (ruff/vulture/jscpd). It is a module function, not a method, because the tests call TtsWindow._ensure_openai_consent and _revert_provider_to_piper unbound with SimpleNamespace fakes. No logging was added on purpose; that is a separate step.

How did you test it?

Baseline on main vs. this branch, QT_QPA_PLATFORM=offscreen WHISPER_GUI_TESTS=1:

main this branch
pytest tests/ 684 passed 684 passed
ruff app/tts_window.py (0.16.8, default rules) 41 31
ruff repo total 297 287

git diff --check is clean.

AI assistance

Yes. The refactor was reconstructed and verified with Claude Code (Claude Sonnet 5) from an earlier audit; the diff was reviewed before committing.

Checklist

  • I ran pytest tests/ (offscreen) or explained why not.
  • I did not commit API keys, tokens, private recordings, or confidential transcripts.
  • I considered whether this changes privacy, security, or data flow. (No: config persistence behavior is unchanged.)
  • I kept the change focused on the Linux scope.

🤖 Generated with Claude Code

Replace six identical try/except/pass config-save blocks in TtsWindow
with a module-level helper next to _safe_unlink(). The helper is a
module function rather than a method because tests call
TtsWindow._ensure_openai_consent and _revert_provider_to_piper unbound
with SimpleNamespace fakes. _on_speed_changed is left as is: its try
also covers the tts_speed property setter, which can raise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@TimInTech
TimInTech merged commit 5fbe28d into main Sep 18, 2026
9 checks passed
@TimInTech
TimInTech deleted the refactor/tts-save-config-helper branch September 18, 2026 22:12
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