mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
cf5d0c9e95
commit
72e999d4be
2 changed files with 6 additions and 8 deletions
|
|
@ -197,13 +197,11 @@ def _convert_to_content(
|
|||
else:
|
||||
other_content.append(item)
|
||||
|
||||
if len(other_content) == 1:
|
||||
if other_content:
|
||||
other_content = _convert_to_content(
|
||||
other_content[0], serializer=serializer, _process_as_single_item=True
|
||||
)
|
||||
elif len(other_content) > 1:
|
||||
other_content = _convert_to_content(
|
||||
other_content, serializer=serializer, _process_as_single_item=True
|
||||
other_content[0] if len(other_content) == 1 else other_content,
|
||||
serializer=serializer,
|
||||
_process_as_single_item=True,
|
||||
)
|
||||
|
||||
return other_content + mcp_types
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
from mcp.types import EmbeddedResource, ImageContent, TextContent, TextResourceContents
|
||||
from pydantic import AnyUrl, BaseModel
|
||||
from pydantic import AnyUrl
|
||||
|
||||
from fastmcp import FastMCP, Image
|
||||
from fastmcp.client import Client
|
||||
|
|
@ -520,7 +520,7 @@ class TestConvertResultToContent:
|
|||
assert image_item.data == "ZmFrZWltYWdlZGF0YQ=="
|
||||
|
||||
def test_list_of_mixed_types_list(self):
|
||||
"""Test that a list of mixed types is converted correctly."""
|
||||
"""Test that a list of mixed types, including a list as one of the elements, is converted correctly."""
|
||||
content1 = TextContent(type="text", text="hello")
|
||||
image_obj = Image(data=b"fakeimagedata")
|
||||
basic_data = [{"a": 1}, {"b": 2}]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue