diff --git a/beets/util/pipeline.py b/beets/util/pipeline.py index 5387186b4..d797dea13 100644 --- a/beets/util/pipeline.py +++ b/beets/util/pipeline.py @@ -160,7 +160,7 @@ R = TypeVar("R") def stage( func: Callable[ [Unpack[A], T], - R, + Optional[R], ], ): """Decorate a function to become a simple stage. @@ -176,7 +176,7 @@ def stage( [3, 4, 5] """ - def coro(*args: Unpack[A]) -> Generator[Union[R, T, None], T, None]: + def coro(*args: Unpack[A]) -> Generator[Union[R, T, None], T, R]: task = None while True: task = yield task @@ -185,7 +185,7 @@ def stage( return coro -def mutator_stage(func: Callable[[Unpack[A], T], None]): +def mutator_stage(func: Callable[[Unpack[A], T], R]): """Decorate a function that manipulates items in a coroutine to become a simple stage. @@ -200,7 +200,7 @@ def mutator_stage(func: Callable[[Unpack[A], T], None]): [{'x': True}, {'a': False, 'x': True}] """ - def coro(*args: Unpack[A]) -> Generator[Optional[T], T, None]: + def coro(*args: Unpack[A]) -> Generator[Union[T, None], T, None]: task = None while True: task = yield task diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index fd6112d7c..a3c640109 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -14,6 +14,8 @@ """Tests for the 'lyrics' plugin.""" +import importlib.util +import os import re from functools import partial from http import HTTPStatus @@ -22,15 +24,15 @@ import pytest from beets.library import Item from beets.test.helper import PluginMixin - -try: - from beetsplug import lyrics -except Exception: - pytest.skip("lyrics plugin couldn't be loaded", allow_module_level=True) - +from beetsplug import lyrics from .lyrics_pages import LyricsPage, lyrics_pages +github_ci = os.environ.get("GITHUB_ACTIONS") == "true" +if not github_ci and not importlib.util.find_spec("langdetect"): + pytest.skip("langdetect isn't available", allow_module_level=True) + + PHRASE_BY_TITLE = { "Lady Madonna": "friday night arrives without a suitcase", "Jazz'n'blues": "as i check my balance i kiss the screen",