refactor(file_transcriber): extract methods from FileTranscriber.run to fix R0915#1539
Merged
raivisdejus merged 16 commits intoJul 1, 2026
Conversation
Decompose ModelDownloader.download_model (142 statements, > 50 limit) into four focused helpers: _prepare_resume_download - existing file validation & resume logic _check_range_support - server Range-request capability _stream_download - HTTP streaming with progress/cancel _verify_sha256 - post-download integrity check download_model now acts as a high-level orchestrator (~16 statements).
…many-statements (R0915)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1539 +/- ##
==========================================
+ Coverage 82.85% 82.88% +0.02%
==========================================
Files 108 108
Lines 11627 11653 +26
==========================================
+ Hits 9634 9659 +25
- Misses 1993 1994 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
raivisdejus
enabled auto-merge (squash)
July 1, 2026 12:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this change needed?
The
FileTranscriber.runmethod had 58 statements, exceeding Pylint's limit of 50 (too-many-statements/ R0915). This made the method overly long and difficult to read, test, and maintain. It mixed three distinct responsibilities:How was it tested?
uv run pytest tests/transcriber/ -vtest_missing_fileinwhisper_file_transcriber_test— a UnicodeDecodeError in theavlibrary)Your code has been rated at 10.00/10What was changed?
Two private helper methods were extracted from
run:_download_from_url(self) -> bool— encapsulates the entire URL import flow: video title extraction, yt-dlp download, ffmpeg conversion to WAV, and Windows-specific subprocess handling. ReturnsFalseon download failure soruncan abort early._handle_folder_watch(self)— encapsulates the FOLDER_WATCH source file management (remove or move).The
runmethod was simplified from ~58 statements to ~20, now acting as a clear orchestrator of these steps.Notes for the reviewer
_download_from_urlmethod returns aboolinstead of raising an exception on download failure. This is intentional: the original code used a barereturnto exitrunearly when the download failed, and a boolean return preserves that control flow cleanly without introducing exception-based control flow.