11import asyncio
22import json
3- from typing import Any
3+ from typing import Any , Optional
44
55import 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
175180async 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