Skip to content

refactor(buzz): group video params into _VideoParams dataclass in FfmpegFrameReader#1543

Merged
raivisdejus merged 19 commits into
chidiwilliams:mainfrom
josiasdev:refactor/remove-code-smell-too-many-instance-attributes-buzz.ffmpeg_video_player
Jul 1, 2026
Merged

refactor(buzz): group video params into _VideoParams dataclass in FfmpegFrameReader#1543
raivisdejus merged 19 commits into
chidiwilliams:mainfrom
josiasdev:refactor/remove-code-smell-too-many-instance-attributes-buzz.ffmpeg_video_player

Conversation

@josiasdev

Copy link
Copy Markdown
Contributor

Why this change is necessary

The FfmpegFrameReader class had 12 instance attributes, exceeding Pylint's default limit of 7 (R0902). This code smell reduces readability and makes the class harder to maintain. The high number of attributes suggests the class has too many responsibilities that could be better organized.

How it was tested

  • Ran pylint --disable=all --enable=R0902 buzz/ffmpeg_video_player.py — no more warnings for FfmpegFrameReader
  • Verified the existing test suite still passes after the change

Notes for the reviewer

The refactoring groups 6 immutable configuration attributes (_file_path, _width, _height, _fps, _frame_size, _start_ms) into a single _VideoParams dataclass. All remaining instance attributes (_lock, _frames, _done, _stop_event, _proc, _thread) are runtime state that changes during the reader's lifecycle, making the separation between configuration and mutable state clearer.

The replaceAll operation during the rename inadvertently affected FfmpegVideoPlayer (which also had self._file_path), but this was corrected before the final commit. Please double-check that FfmpegVideoPlayer references are intact.

josiasdev and others added 19 commits June 17, 2026 16:42
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).
…statements (R0915)

Extraiu 7 métodos auxiliares e 3 funções modulares do método
transcribe (166 statements, limite 50), reduzindo-o para ~30 statements.

Métodos extraídos para WhisperCpp:
  - _convert_to_wav, _build_command, _run_whisper
  - _read_json_output, _parse_word_level_timings
  - _parse_segment_timings, _cleanup_files

Funções extraídas para o módulo:
  - _make_offset_mapper, _flush_complete_chars, _append_word
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.95%. Comparing base (a591037) to head (489f2fd).

Files with missing lines Patch % Lines
buzz/file_transcriber_queue_worker.py 83.33% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1543      +/-   ##
==========================================
+ Coverage   82.94%   82.95%   +0.01%     
==========================================
  Files         108      108              
  Lines       11668    11675       +7     
==========================================
+ Hits         9678     9685       +7     
  Misses       1990     1990              
Flag Coverage Δ
Linux 81.68% <86.66%> (+0.01%) ⬆️
macOS 82.46% <86.66%> (+0.01%) ⬆️

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.

@raivisdejus raivisdejus enabled auto-merge (squash) July 1, 2026 14:58
@raivisdejus raivisdejus merged commit 8a2a3de 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