From 7e2f7d3e4f164e872c81840c48e049fb786b9bbc Mon Sep 17 00:00:00 2001 From: Marvin Schenkel Date: Tue, 25 Nov 2025 09:10:18 +0100 Subject: [PATCH] Fix handler type of register_api_command --- music_assistant/helpers/api.py | 6 +++--- music_assistant/mass.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/music_assistant/helpers/api.py b/music_assistant/helpers/api.py index 1cc336ef..53403986 100644 --- a/music_assistant/helpers/api.py +++ b/music_assistant/helpers/api.py @@ -4,7 +4,7 @@ from __future__ import annotations import inspect import logging -from collections.abc import Callable, Coroutine +from collections.abc import AsyncGenerator, Callable, Coroutine from dataclasses import MISSING, dataclass from datetime import datetime from enum import Enum @@ -27,11 +27,11 @@ class APICommandHandler: command: str signature: inspect.Signature type_hints: dict[str, Any] - target: Callable[..., Coroutine[Any, Any, Any]] + target: Callable[..., Coroutine[Any, Any, Any] | AsyncGenerator[Any, Any]] @classmethod def parse( - cls, command: str, func: Callable[..., Coroutine[Any, Any, Any]] + cls, command: str, func: Callable[..., Coroutine[Any, Any, Any] | AsyncGenerator[Any, Any]] ) -> APICommandHandler: """Parse APICommandHandler by providing a function.""" type_hints = get_type_hints(func) diff --git a/music_assistant/mass.py b/music_assistant/mass.py index 3cec1424..3dad39f4 100644 --- a/music_assistant/mass.py +++ b/music_assistant/mass.py @@ -7,7 +7,7 @@ import logging import os import pathlib import threading -from collections.abc import Awaitable, Callable, Coroutine +from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine from typing import TYPE_CHECKING, Any, Self, TypeGuard, TypeVar, cast from uuid import uuid4 @@ -482,7 +482,7 @@ class MusicAssistant: def register_api_command( self, command: str, - handler: Callable[..., Coroutine[Any, Any, Any]], + handler: Callable[..., Coroutine[Any, Any, Any] | AsyncGenerator[Any, Any]], ) -> Callable[[], None]: """ Dynamically register a command on the API. -- 2.34.1