Skip to content

Commit 0c33a24

Browse files
committed
fix: resolve linting issues
1 parent a81da67 commit 0c33a24

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Diff for: src/agents/function_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FuncSchema:
3636
strict_json_schema: bool = True
3737
"""Whether the JSON schema is in strict mode. We **strongly** recommend setting this to True,
3838
as it increases the likelihood of correct JSON input."""
39-
39+
4040
def to_call_args(self, data: BaseModel) -> tuple[list[Any], dict[str, Any]]:
4141
"""
4242
Converts validated data from the Pydantic model into (args, kwargs), suitable for calling

Diff for: src/agents/tool.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ def function_tool(
189189
failure_error_function: If provided, use this function to generate an error message when
190190
the tool call fails. The error message is sent to the LLM. If you pass None, then no
191191
error message will be sent and instead an Exception will be raised.
192-
strict_mode: If False, parameters with default values become optional in the function schema.
192+
strict_mode: If False, parameters with default values become optional in the
193+
function schema.
193194
"""
194195

195196
def _create_function_tool(the_func: ToolFunction[...]) -> FunctionTool:

Diff for: tests/test_function_tool_decorator.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import json
3-
from typing import Any
3+
from typing import Any, Optional
44

55
import pytest
66

@@ -145,7 +145,7 @@ async def test_no_error_on_invalid_json_async():
145145

146146

147147
@function_tool(strict_mode=False)
148-
def optional_param_function(a: int, b: int | None = None) -> str:
148+
def optional_param_function(a: int, b: Optional[int] = None) -> str:
149149
if b is None:
150150
return f"{a}_no_b"
151151
return f"{a}_{b}"
@@ -165,17 +165,22 @@ async def test_optional_param_function():
165165

166166

167167
@function_tool(strict_mode=False)
168-
def multiple_optional_params_function(x: int = 42, y: str = "hello", z: int | None = None) -> str:
168+
def multiple_optional_params_function(
169+
x: int = 42,
170+
y: str = "hello",
171+
z: Optional[int] = None,
172+
) -> str:
169173
if z is None:
170174
return f"{x}_{y}_no_z"
171175
return f"{x}_{y}_{z}"
172176

173177

178+
174179
@pytest.mark.asyncio
175180
async def test_multiple_optional_params_function():
176181
tool = multiple_optional_params_function
177182

178-
input_data = {}
183+
input_data: dict[str,Any] = {}
179184
output = await tool.on_invoke_tool(ctx_wrapper(), json.dumps(input_data))
180185
assert output == "42_hello_no_z"
181186

@@ -185,4 +190,4 @@ async def test_multiple_optional_params_function():
185190

186191
input_data = {"x": 10, "y": "world", "z": 99}
187192
output = await tool.on_invoke_tool(ctx_wrapper(), json.dumps(input_data))
188-
assert output == "10_world_99"
193+
assert output == "10_world_99"

0 commit comments

Comments
 (0)