Skip to content

Commit a04bc72

Browse files
committed
fixed typing in test
1 parent 356815f commit a04bc72

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

maseval/interface/agents/llamaindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _install_hooks(self):
306306
from llama_index_instrumentation import get_dispatcher
307307

308308
dispatcher = get_dispatcher()
309-
dispatcher.add_span_handler(self._span_handler)
309+
dispatcher.add_span_handler(self._span_handler) # type: ignore[invalid-argument-type] # duck-typed handler
310310
except (ImportError, Exception):
311311
pass
312312

tests/test_interface/test_agent_integration/test_langgraph_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class State(TypedDict):
382382
messages: list
383383

384384
graph = StateGraph(State) # type: ignore[arg-type]
385-
graph.add_node("agent", lambda s: s)
385+
graph.add_node("agent", lambda s: s) # type: ignore[invalid-argument-type]
386386
graph.set_entry_point("agent")
387387
graph.add_edge("agent", END)
388388
compiled = graph.compile()

tests/test_interface/test_agent_integration/test_smolagents_integration.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def test_smolagents_llm_user_get_tool():
611611
def test_smolagents_message_conversion_tool_call_attributes():
612612
"""Test _convert_smolagents_messages preserves tool_calls from ChatMessage objects."""
613613
from maseval.interface.agents.smolagents import SmolAgentAdapter
614-
from smolagents.models import ChatMessage, MessageRole
614+
from smolagents.models import ChatMessage, ChatMessageToolCall, ChatMessageToolCallFunction, MessageRole
615615
from unittest.mock import Mock
616616

617617
mock_agent = Mock()
@@ -621,18 +621,23 @@ def test_smolagents_message_conversion_tool_call_attributes():
621621

622622
adapter = SmolAgentAdapter(agent_instance=mock_agent, name="msg_agent")
623623

624-
# Create ChatMessage with tool_calls attribute
625-
msg = ChatMessage(role=MessageRole.ASSISTANT, content="Using tool")
626-
msg.tool_calls = [{"id": "call_1", "function": {"name": "search", "arguments": '{"q": "test"}'}}]
624+
# Create ChatMessage with tool_calls attribute using proper types
625+
tool_call = ChatMessageToolCall(
626+
id="call_1",
627+
type="function",
628+
function=ChatMessageToolCallFunction(name="search", arguments='{"q": "test"}'),
629+
)
630+
msg = ChatMessage(role=MessageRole.ASSISTANT, content="Using tool", tool_calls=[tool_call])
627631

628632
history = adapter._convert_smolagents_messages([msg])
629633

630634
assert len(history) == 1
631635
assert history[0]["role"] == "assistant"
632636
assert history[0]["content"] == "Using tool"
633637
assert "tool_calls" in history[0]
634-
assert history[0]["tool_calls"][0]["id"] == "call_1"
635-
assert history[0]["tool_calls"][0]["function"]["name"] == "search"
638+
assert len(history[0]["tool_calls"]) == 1
639+
assert history[0]["tool_calls"][0].id == "call_1"
640+
assert history[0]["tool_calls"][0].function.name == "search"
636641

637642

638643
# =============================================================================

0 commit comments

Comments
 (0)