|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | from inspect import Parameter, signature
|
16 |
| -from typing import Any, Optional |
| 16 | +from typing import Annotated, Any, Optional |
17 | 17 |
|
18 | 18 | import pytest
|
19 | 19 | import pytest_asyncio
|
@@ -243,15 +243,24 @@ async def test_tool_signature_is_correct(self, toolbox: ToolboxClient):
|
243 | 243 |
|
244 | 244 | # The required parameter should have no default
|
245 | 245 | assert sig.parameters["email"].default is Parameter.empty
|
246 |
| - assert sig.parameters["email"].annotation is str |
| 246 | + assert ( |
| 247 | + sig.parameters["email"].annotation |
| 248 | + is Annotated[str, "The email to search for."] |
| 249 | + ) |
247 | 250 |
|
248 | 251 | # The optional parameter should have a default of None
|
249 | 252 | assert sig.parameters["data"].default is None
|
250 |
| - assert sig.parameters["data"].annotation is Optional[str] |
| 253 | + assert ( |
| 254 | + sig.parameters["data"].annotation |
| 255 | + is Annotated[Optional[str], "The row to narrow down the search."] |
| 256 | + ) |
251 | 257 |
|
252 | 258 | # The optional parameter should have a default of None
|
253 | 259 | assert sig.parameters["id"].default is None
|
254 |
| - assert sig.parameters["id"].annotation is Optional[int] |
| 260 | + assert ( |
| 261 | + sig.parameters["id"].annotation |
| 262 | + is Annotated[Optional[int], "The id to narrow down the search."] |
| 263 | + ) |
255 | 264 |
|
256 | 265 | async def test_run_tool_with_optional_params_omitted(self, toolbox: ToolboxClient):
|
257 | 266 | """Invoke a tool providing only the required parameter."""
|
@@ -395,15 +404,27 @@ async def test_tool_signature_with_map_params(self, toolbox: ToolboxClient):
|
395 | 404 | sig = signature(tool)
|
396 | 405 |
|
397 | 406 | assert "execution_context" in sig.parameters
|
398 |
| - assert sig.parameters["execution_context"].annotation == dict[str, Any] |
| 407 | + assert ( |
| 408 | + sig.parameters["execution_context"].annotation |
| 409 | + == Annotated[ |
| 410 | + dict[str, Any], |
| 411 | + "A flexible set of key-value pairs for the execution environment.", |
| 412 | + ] |
| 413 | + ) |
399 | 414 | assert sig.parameters["execution_context"].default is Parameter.empty
|
400 | 415 |
|
401 | 416 | assert "user_scores" in sig.parameters
|
402 |
| - assert sig.parameters["user_scores"].annotation == dict[str, int] |
| 417 | + assert ( |
| 418 | + sig.parameters["user_scores"].annotation |
| 419 | + == Annotated[dict[str, int], "A map of user IDs to their scores."] |
| 420 | + ) |
403 | 421 | assert sig.parameters["user_scores"].default is Parameter.empty
|
404 | 422 |
|
405 | 423 | assert "feature_flags" in sig.parameters
|
406 |
| - assert sig.parameters["feature_flags"].annotation == Optional[dict[str, bool]] |
| 424 | + assert ( |
| 425 | + sig.parameters["feature_flags"].annotation |
| 426 | + == Annotated[Optional[dict[str, bool]], "Optional feature flags."] |
| 427 | + ) |
407 | 428 | assert sig.parameters["feature_flags"].default is None
|
408 | 429 |
|
409 | 430 | async def test_run_tool_with_map_params(self, toolbox: ToolboxClient):
|
|
0 commit comments