Deprecate roots, sampling, and logging methods per SEP-2577 (#2926)

This commit is contained in:
Marcelo Trylesinski 2026-06-20 17:25:41 +01:00 • committed by GitHub
commit 4573e4ac33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 206 additions and 123 deletions

View file

@ -259,7 +259,7 @@ async def test_client_unsubscribe_resource(simple_server: Server):
async def test_client_set_logging_level(simple_server: Server):
"""Test setting logging level."""
async with Client(simple_server) as client:
result = await client.set_logging_level("debug")
result = await client.set_logging_level("debug") # pyright: ignore[reportDeprecated]
assert result == snapshot(EmptyResult())

View file

@ -25,7 +25,7 @@ async def test_list_roots_callback():
@server.tool("test_list_roots")
async def test_list_roots(context: Context, message: str):
roots = await context.session.list_roots()
roots = await context.session.list_roots() # pyright: ignore[reportDeprecated]
assert roots == callback_return
return True

View file

@ -36,7 +36,7 @@ async def test_logging_callback():
message: str, level: Literal["debug", "info", "warning", "error"], logger: str, ctx: Context
) -> bool:
"""Send a log notification to the client."""
await ctx.log(level=level, data=message, logger_name=logger)
await ctx.log(level=level, data=message, logger_name=logger) # pyright: ignore[reportDeprecated]
return True
@server.tool("test_tool_with_log_dict")
@ -46,7 +46,7 @@ async def test_logging_callback():
ctx: Context,
) -> bool:
"""Send a log notification with a dict payload."""
await ctx.log(
await ctx.log( # pyright: ignore[reportDeprecated]
level=level,
data={"message": "Test log message", "extra_string": "example", "extra_dict": {"a": 1, "b": 2, "c": 3}},
logger_name=logger,

View file

@ -32,7 +32,7 @@ async def test_sampling_callback():
@server.tool("test_sampling")
async def test_sampling_tool(message: str, ctx: Context) -> bool:
value = await ctx.session.create_message(
value = await ctx.session.create_message( # pyright: ignore[reportDeprecated]
messages=[SamplingMessage(role="user", content=TextContent(type="text", text=message))],
max_tokens=100,
)
@ -78,7 +78,7 @@ async def test_create_message_backwards_compat_single_content():
@server.tool("test_backwards_compat")
async def test_tool(message: str, ctx: Context) -> bool:
# Call create_message WITHOUT tools
result = await ctx.session.create_message(
result = await ctx.session.create_message( # pyright: ignore[reportDeprecated]
messages=[SamplingMessage(role="user", content=TextContent(type="text", text=message))],
max_tokens=100,
)

View file

@ -95,7 +95,7 @@ async def test_overlapping_sampling_requests_are_serviced_concurrently_by_the_cl
echoes: dict[str, str] = {}
async def sample(tag: str) -> None:
result = await ctx.session.create_message(
result = await ctx.session.create_message( # pyright: ignore[reportDeprecated]
messages=[SamplingMessage(role="user", content=TextContent(text=tag))],
max_tokens=10,
)