Skip to content

refactor(advanced-settings-dialog): extract __init__ into smaller methods to fix R0914#1538

Merged
raivisdejus merged 7 commits into
chidiwilliams:mainfrom
josiasdev:refactor/remove-code-smell-advanced-settings-init-R0914
Jul 1, 2026
Merged

refactor(advanced-settings-dialog): extract __init__ into smaller methods to fix R0914#1538
raivisdejus merged 7 commits into
chidiwilliams:mainfrom
josiasdev:refactor/remove-code-smell-advanced-settings-init-R0914

Conversation

@josiasdev

Copy link
Copy Markdown
Contributor

Why this change is necessary

The __init__ method of AdvancedSettingsDialog had 144 statements, far exceeding Pylint's default limit of 50 (R0914 – too-many-statements). This made the method hard to read, test, and maintain. All UI construction logic was concentrated in a single method.

How it was tested

  • Run pytest -k advanced_settings19/19 tests passed (the only failure in the suite is a pre-existing locale issue in TestLanguagesComboBox, unrelated to this change)
  • Pylint check with --enable=R0914 now passes with a score of 10.00/10
  • Python syntax verified with ast.parse

Notes for the reviewer

The refactoring is purely structural — no behavior or logic was changed. The original __init__ body was split into four private methods:

Method Responsibility
_setup_transcription_section Initial prompt widget
_setup_translation_section LLM translation checkbox, model, prompt, info button
_setup_recording_section Silence threshold, recording mode, line separator, transcription step, hide unconfirmed, export settings
_setup_button_box OK button

All references to the local parameter transcription_options inside the extracted methods were changed to self.transcription_options (the instance attribute already set in __init__).

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.86%. Comparing base (f00473f) to head (35bcc7e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1538      +/-   ##
==========================================
+ Coverage   82.83%   82.86%   +0.03%     
==========================================
  Files         108      108              
  Lines       11620    11627       +7     
==========================================
+ Hits         9625     9635      +10     
+ Misses       1995     1992       -3     
Flag Coverage Δ
Linux 81.62% <100.00%> (+0.01%) ⬆️
macOS 82.37% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ve-code-smell-advanced-settings-init-R0914

# Conflicts:
#	buzz/widgets/transcription_viewer/speaker_identification_widget.py
@raivisdejus
raivisdejus enabled auto-merge (squash) July 1, 2026 12:07
@raivisdejus
raivisdejus merged commit b756a47 into chidiwilliams:main Jul 1, 2026
17 of 19 checks passed
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.

2 participants