Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
William Easton 2025-05-31 15:48:43 -05:00 committed by GitHub
commit 72e999d4be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View file

@ -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

View file

@ -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}]