mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Fix music_assistant decorator typing (#133044)
This commit is contained in:
parent
8e15287662
commit
4b5d717898
@ -3,11 +3,11 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Awaitable, Callable, Coroutine, Mapping
|
from collections.abc import Callable, Coroutine, Mapping
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any, Concatenate
|
||||||
|
|
||||||
from music_assistant_models.enums import (
|
from music_assistant_models.enums import (
|
||||||
EventType,
|
EventType,
|
||||||
@ -102,14 +102,14 @@ ATTR_AUTO_PLAY = "auto_play"
|
|||||||
|
|
||||||
|
|
||||||
def catch_musicassistant_error[_R, **P](
|
def catch_musicassistant_error[_R, **P](
|
||||||
func: Callable[..., Awaitable[_R]],
|
func: Callable[Concatenate[MusicAssistantPlayer, P], Coroutine[Any, Any, _R]],
|
||||||
) -> Callable[..., Coroutine[Any, Any, _R | None]]:
|
) -> Callable[Concatenate[MusicAssistantPlayer, P], Coroutine[Any, Any, _R]]:
|
||||||
"""Check and log commands to players."""
|
"""Check and log commands to players."""
|
||||||
|
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
async def wrapper(
|
async def wrapper(
|
||||||
self: MusicAssistantPlayer, *args: P.args, **kwargs: P.kwargs
|
self: MusicAssistantPlayer, *args: P.args, **kwargs: P.kwargs
|
||||||
) -> _R | None:
|
) -> _R:
|
||||||
"""Catch Music Assistant errors and convert to Home Assistant error."""
|
"""Catch Music Assistant errors and convert to Home Assistant error."""
|
||||||
try:
|
try:
|
||||||
return await func(self, *args, **kwargs)
|
return await func(self, *args, **kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user