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