🐛 | Code quality fixes
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m43s

- config.py: move 'import shutil' to module level
- player.py: unify type hints, narrow except, add debug log
- discord_rpc.py: replace broad except Exception with specific types
- gui.py: remove unused import; replace lambda closures with method refs; fix closure scope bug; extract _populate_list_page() to remove duplicate code; add public accessors; make flush_volume public; add AudioVisualizer.reset_activity()
- tests: replace unused _f variable with Path.touch()
This commit is contained in:
2026-06-04 18:26:46 +03:00
parent 82a34a0a55
commit daf9c5739c
5 changed files with 85 additions and 63 deletions

View File

@@ -39,6 +39,9 @@ import shutil
import threading
from typing import Optional
# In this module we use Optional[str] for consistency
# with Qt signal/slot typing conventions.
import yt_dlp
# ═══════════════════════════════════════════════════════════════════════════
@@ -75,7 +78,7 @@ VERBOSE: bool = False # enable yt-dlp debug output
# Temp-file housekeeping
# ═══════════════════════════════════════════════════════════════════════════════
_TUNETTI_TMP: str | None = None
_TUNETTI_TMP: Optional[str] = None
def _tmp_dir() -> str:
@@ -166,6 +169,8 @@ class DownloadWorker(QObject):
@Slot(int, dict)
def _do_download(self, task_id: int, song: dict) -> None:
"""Entry point — invoked on the worker thread."""
log.debug("Download starting: task_id=%d, video_id=%s",
task_id, song.get("videoId") or song.get("video_id", ""))
self._task_id = task_id
self._cancelled = False
@@ -232,7 +237,7 @@ class DownloadWorker(QObject):
if not self._cancelled:
self.download_succeeded.emit(task_id, resolved)
except Exception as exc:
except (OSError, RuntimeError) as exc:
log.error("Download error for %s: %s", video_id, exc)
self._cleanup_path(temp_path)
with self._lock: