@@ -335,18 +335,14 @@ def mock_log_error(msg, *args):
335
335
logged_errors .append (msg % args if args else msg )
336
336
337
337
# Create a progress callback that raises an exception
338
- async def failing_progress_callback (
339
- progress : float , total : float | None , message : str | None
340
- ) -> None :
338
+ async def failing_progress_callback (progress : float , total : float | None , message : str | None ) -> None :
341
339
raise ValueError ("Progress callback failed!" )
342
340
343
341
# Create a server with a tool that sends progress notifications
344
342
server = Server (name = "TestProgressServer" )
345
343
346
344
@server .call_tool ()
347
- async def handle_call_tool (
348
- name : str , arguments : dict | None
349
- ) -> list [types .TextContent ]:
345
+ async def handle_call_tool (name : str , arguments : dict | None ) -> list [types .TextContent ]:
350
346
if name == "progress_tool" :
351
347
# Send a progress notification
352
348
await server .request_context .session .send_progress_notification (
@@ -376,9 +372,7 @@ async def handle_list_tools() -> list[types.Tool]:
376
372
types .ClientRequest (
377
373
types .CallToolRequest (
378
374
method = "tools/call" ,
379
- params = types .CallToolRequestParams (
380
- name = "progress_tool" , arguments = {}
381
- ),
375
+ params = types .CallToolRequestParams (name = "progress_tool" , arguments = {}),
382
376
)
383
377
),
384
378
types .CallToolResult ,
@@ -388,12 +382,9 @@ async def handle_list_tools() -> list[types.Tool]:
388
382
# Verify the request completed successfully despite the callback failure
389
383
assert len (result .content ) == 1
390
384
content = result .content [0 ]
391
- assert isinstance (content , TextContent )
385
+ assert isinstance (content , types . TextContent )
392
386
assert content .text == "progress_result"
393
387
394
388
# Check that a warning was logged for the progress callback exception
395
389
assert len (logged_errors ) > 0
396
- assert any (
397
- "Progress callback raised an exception" in warning
398
- for warning in logged_errors
399
- )
390
+ assert any ("Progress callback raised an exception" in warning for warning in logged_errors )
0 commit comments