Make call_tool() return value covariant

`list` is invariant, hence handlers can't just return `list[str]`.
We need to use Sequence here.
This commit is contained in:
David Soria Parra 2024-11-10 21:47:26 +00:00
commit 935fe5d1a0
No known key found for this signature in database

View file

@ -2,7 +2,7 @@ import contextvars
import logging import logging
import warnings import warnings
from collections.abc import Awaitable, Callable from collections.abc import Awaitable, Callable
from typing import Any from typing import Any, Sequence
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
from pydantic import AnyUrl from pydantic import AnyUrl
@ -337,7 +337,7 @@ class Server:
def decorator( def decorator(
func: Callable[ func: Callable[
..., Awaitable[list[str | types.ImageContent | types.EmbeddedResource]] ..., Awaitable[Sequence[str | types.ImageContent | types.EmbeddedResource]]
], ],
): ):
logger.debug("Registering handler for CallToolRequest") logger.debug("Registering handler for CallToolRequest")