Skip to content

Commit 6b8e7b9

Browse files
committed
fix quality check
1 parent 9eef2d9 commit 6b8e7b9

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/sap_cloud_sdk/agentgateway/converters.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
if TYPE_CHECKING:
1717
from langchain_core.tools import StructuredTool
1818

19+
_JSON_TYPE_MAP: dict[str, type] = {
20+
"string": str,
21+
"integer": int,
22+
"number": float,
23+
"boolean": bool,
24+
"array": list,
25+
"object": dict,
26+
}
27+
1928

2029
def mcp_tool_to_langchain(
2130
mcp_tool: MCPTool,
@@ -79,23 +88,17 @@ async def run(**kwargs) -> str:
7988
**resolved,
8089
)
8190

82-
_JSON_TYPE_MAP: dict[str, type] = {
83-
"string": str,
84-
"integer": int,
85-
"number": float,
86-
"boolean": bool,
87-
"array": list,
88-
"object": dict,
89-
}
90-
9191
# Build args schema from input_schema
9292
properties = mcp_tool.input_schema.get("properties", {})
9393
required = set(mcp_tool.input_schema.get("required", []))
9494
fields: dict[str, Any] = {
9595
k: (
9696
(_JSON_TYPE_MAP.get(v.get("type", ""), Any), ...)
9797
if k in required
98-
else (_JSON_TYPE_MAP.get(v.get("type", ""), Any) | None, Field(default=None))
98+
else (
99+
_JSON_TYPE_MAP.get(v.get("type", ""), Any) | None,
100+
Field(default=None),
101+
)
99102
)
100103
for k, v in properties.items()
101104
}

tests/agentgateway/unit/test_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_input_schema_without_properties_key(self):
9292
class TestMcpToolToLangchainTypeMapping:
9393
"""Tests that JSON Schema types are mapped to the correct Python types."""
9494

95-
def _tool_with_types(self, properties: dict, required: list[str] | None = None) -> object:
95+
def _tool_with_types(self, properties: dict, required: list[str] | None = None) -> MCPTool:
9696
return MCPTool(
9797
name="typed_tool",
9898
server_name="server",

0 commit comments

Comments
 (0)