mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Fix plugin types
This commit is contained in:
parent
d3c64d8506
commit
816d06f160
3 changed files with 13 additions and 9 deletions
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import librosa
|
||||
import numpy as np
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand, should_write
|
||||
|
|
@ -76,7 +76,10 @@ class AutoBPMPlugin(BeetsPlugin):
|
|||
self._log.error("Failed to measure BPM for {}: {}", path, exc)
|
||||
continue
|
||||
|
||||
bpm = round(tempo[0] if isinstance(tempo, Iterable) else tempo)
|
||||
bpm = round(
|
||||
float(tempo[0] if isinstance(tempo, np.ndarray) else tempo)
|
||||
)
|
||||
|
||||
item["bpm"] = bpm
|
||||
self._log.info("Computed BPM for {}: {}", path, bpm)
|
||||
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
label = "album"
|
||||
|
||||
if not new_genres and "artist" in self.sources:
|
||||
new_genres = None
|
||||
new_genres = []
|
||||
if isinstance(obj, library.Item):
|
||||
new_genres = self.fetch_artist_genre(obj)
|
||||
label = "artist"
|
||||
|
|
|
|||
|
|
@ -1161,7 +1161,9 @@ class ExceptionWatcher(Thread):
|
|||
Once an exception occurs, raise it and execute a callback.
|
||||
"""
|
||||
|
||||
def __init__(self, queue: queue.Queue, callback: Callable[[], None]):
|
||||
def __init__(
|
||||
self, queue: queue.Queue[Exception], callback: Callable[[], None]
|
||||
):
|
||||
self._queue = queue
|
||||
self._callback = callback
|
||||
self._stopevent = Event()
|
||||
|
|
@ -1197,7 +1199,9 @@ BACKENDS: dict[str, type[Backend]] = {b.NAME: b for b in BACKEND_CLASSES}
|
|||
class ReplayGainPlugin(BeetsPlugin):
|
||||
"""Provides ReplayGain analysis."""
|
||||
|
||||
def __init__(self):
|
||||
pool: ThreadPool | None = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
# default backend is 'command' for backward-compatibility.
|
||||
|
|
@ -1261,9 +1265,6 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
except (ReplayGainError, FatalReplayGainError) as e:
|
||||
raise ui.UserError(f"replaygain initialization failed: {e}")
|
||||
|
||||
# Start threadpool lazily.
|
||||
self.pool = None
|
||||
|
||||
def should_use_r128(self, item: Item) -> bool:
|
||||
"""Checks the plugin setting to decide whether the calculation
|
||||
should be done using the EBU R128 standard and use R128_ tags instead.
|
||||
|
|
@ -1420,7 +1421,7 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
"""Open a `ThreadPool` instance in `self.pool`"""
|
||||
if self.pool is None and self.backend_instance.do_parallel:
|
||||
self.pool = ThreadPool(threads)
|
||||
self.exc_queue: queue.Queue = queue.Queue()
|
||||
self.exc_queue: queue.Queue[Exception] = queue.Queue()
|
||||
|
||||
signal.signal(signal.SIGINT, self._interrupt)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue