refactor: use snake case instead of camel case in types (#1894)

This commit is contained in:
Marcelo Trylesinski 2026-01-16 15:51:27 +01:00 • committed by GitHub
commit e94b386a13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1063 additions and 1057 deletions

View file

@ -15,14 +15,14 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Auth required",
url="https://example.com/auth",
elicitationId="test-123",
elicitation_id="test-123",
)
error = UrlElicitationRequiredError([elicitation])
assert error.error.code == URL_ELICITATION_REQUIRED
assert error.error.message == "URL elicitation required"
assert len(error.elicitations) == 1
assert error.elicitations[0].elicitationId == "test-123"
assert error.elicitations[0].elicitation_id == "test-123"
def test_create_with_multiple_elicitations(self) -> None:
"""Test creating error with multiple elicitations uses plural message."""
@ -31,13 +31,13 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Auth 1",
url="https://example.com/auth1",
elicitationId="test-1",
elicitation_id="test-1",
),
ElicitRequestURLParams(
mode="url",
message="Auth 2",
url="https://example.com/auth2",
elicitationId="test-2",
elicitation_id="test-2",
),
]
error = UrlElicitationRequiredError(elicitations)
@ -51,7 +51,7 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Auth required",
url="https://example.com/auth",
elicitationId="test-123",
elicitation_id="test-123",
)
error = UrlElicitationRequiredError([elicitation], message="Custom message")
@ -77,7 +77,7 @@ class TestUrlElicitationRequiredError:
error = UrlElicitationRequiredError.from_error(error_data)
assert len(error.elicitations) == 1
assert error.elicitations[0].elicitationId == "test-123"
assert error.elicitations[0].elicitation_id == "test-123"
assert error.elicitations[0].url == "https://example.com/auth"
def test_from_error_data_wrong_code(self) -> None:
@ -99,7 +99,7 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Auth required",
url="https://example.com/auth",
elicitationId="test-123",
elicitation_id="test-123",
)
]
)
@ -110,7 +110,7 @@ class TestUrlElicitationRequiredError:
# Reconstruct
reconstructed = UrlElicitationRequiredError.from_error(error_data)
assert reconstructed.elicitations[0].elicitationId == original.elicitations[0].elicitationId
assert reconstructed.elicitations[0].elicitation_id == original.elicitations[0].elicitation_id
assert reconstructed.elicitations[0].url == original.elicitations[0].url
assert reconstructed.elicitations[0].message == original.elicitations[0].message
@ -120,7 +120,7 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Please authenticate",
url="https://example.com/oauth",
elicitationId="oauth-flow-1",
elicitation_id="oauth-flow-1",
)
error = UrlElicitationRequiredError([elicitation])
@ -138,7 +138,7 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Auth required",
url="https://example.com/auth",
elicitationId="test-123",
elicitation_id="test-123",
)
error = UrlElicitationRequiredError([elicitation])
@ -151,7 +151,7 @@ class TestUrlElicitationRequiredError:
mode="url",
message="Auth required",
url="https://example.com/auth",
elicitationId="test-123",
elicitation_id="test-123",
)
error = UrlElicitationRequiredError([elicitation])

View file

@ -79,7 +79,7 @@ async def test_bidirectional_progress_notifications():
types.Tool(
name="test_tool",
description="A tool that sends progress notifications <o/",
inputSchema={},
input_schema={},
)
]
@ -138,7 +138,7 @@ async def test_bidirectional_progress_notifications():
params = message.root.params
client_progress_updates.append(
{
"token": params.progressToken,
"token": params.progress_token,
"progress": params.progress,
"total": params.total,
"message": params.message,
@ -274,7 +274,7 @@ async def test_progress_context_manager():
progress_token = "client_token_456"
# Create request context
meta = types.RequestParams.Meta(progressToken=progress_token)
meta = types.RequestParams.Meta(progress_token=progress_token)
request_context = RequestContext(
request_id="test-request",
session=client_session,
@ -362,7 +362,7 @@ async def test_progress_callback_exception_logging():
types.Tool(
name="progress_tool",
description="A tool that sends progress notifications",
inputSchema={},
input_schema={},
)
]

View file

@ -82,7 +82,7 @@ async def test_request_cancellation():
types.Tool(
name="slow_tool",
description="A slow tool that takes 10 seconds to complete",
inputSchema={},
input_schema={},
)
]
@ -118,7 +118,7 @@ async def test_request_cancellation():
await client_session.send_notification(
ClientNotification(
CancelledNotification(
params=CancelledNotificationParams(requestId=request_id),
params=CancelledNotificationParams(request_id=request_id),
)
)
)

View file

@ -78,7 +78,7 @@ class ServerTest(Server): # pragma: no cover
Tool(
name="test_tool",
description="A test tool",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
)
]
@ -184,7 +184,7 @@ async def test_sse_client_basic_connection(server: None, server_url: str) -> Non
# Test initialization
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == SERVER_NAME
assert result.server_info.name == SERVER_NAME
# Test ping
ping_result = await session.send_ping()
@ -330,7 +330,7 @@ async def test_sse_client_basic_connection_mounted_app(mounted_server: None, ser
# Test initialization
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == SERVER_NAME
assert result.server_info.name == SERVER_NAME
# Test ping
ping_result = await session.send_ping()
@ -366,12 +366,12 @@ class RequestContextServer(Server[object, Request]): # pragma: no cover
Tool(
name="echo_headers",
description="Echoes request headers",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="echo_context",
description="Echoes request context",
inputSchema={
input_schema={
"type": "object",
"properties": {"request_id": {"type": "string"}},
"required": ["request_id"],
@ -558,9 +558,9 @@ async def test_sse_client_handles_empty_keepalive_pings() -> None:
"""
# Build a proper JSON-RPC response using types (not hardcoded strings)
init_result = InitializeResult(
protocolVersion="2024-11-05",
protocol_version="2024-11-05",
capabilities=ServerCapabilities(),
serverInfo=Implementation(name="test", version="1.0"),
server_info=Implementation(name="test", version="1.0"),
)
response = JSONRPCResponse(
jsonrpc="2.0",

View file

@ -154,47 +154,47 @@ class ServerTest(Server): # pragma: no cover
Tool(
name="test_tool",
description="A test tool",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="test_tool_with_standalone_notification",
description="A test tool that sends a notification",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="long_running_with_checkpoints",
description="A long-running tool that sends periodic notifications",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="test_sampling_tool",
description="A tool that triggers server-side sampling",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="wait_for_lock_with_notification",
description="A tool that sends a notification and waits for lock",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="release_lock",
description="A tool that releases the lock",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="tool_with_stream_close",
description="A tool that closes SSE stream mid-operation",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="tool_with_multiple_notifications_and_close",
description="Tool that sends notification1, closes stream, sends notification2, notification3",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="tool_with_multiple_stream_closes",
description="Tool that closes SSE stream multiple times during execution",
inputSchema={
input_schema={
"type": "object",
"properties": {
"checkpoints": {"type": "integer", "default": 3},
@ -205,7 +205,7 @@ class ServerTest(Server): # pragma: no cover
Tool(
name="tool_with_standalone_stream_close",
description="Tool that closes standalone GET stream mid-operation",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
]
@ -1004,7 +1004,7 @@ async def test_streamable_http_client_basic_connection(basic_server: None, basic
# Test initialization
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == SERVER_NAME
assert result.server_info.name == SERVER_NAME
@pytest.mark.anyio
@ -1084,7 +1084,7 @@ async def test_streamable_http_client_json_response(json_response_server: None,
# Initialize the session
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == SERVER_NAME
assert result.server_info.name == SERVER_NAME
# Check tool listing
tools = await session.list_tools()
@ -1286,7 +1286,7 @@ async def test_streamable_http_client_resumption(event_server: tuple[SimpleEvent
captured_session_id = get_session_id()
assert captured_session_id is not None
# Capture the negotiated protocol version
captured_protocol_version = result.protocolVersion
captured_protocol_version = result.protocol_version
# Start the tool that will wait on lock in a task
async with anyio.create_task_group() as tg:
@ -1395,7 +1395,7 @@ async def test_streamablehttp_server_sampling(basic_server: None, basic_server_u
text=f"Received message from server: {message_received}",
),
model="test-model",
stopReason="endTurn",
stop_reason="endTurn",
)
# Create client with sampling callback
@ -1439,12 +1439,12 @@ class ContextAwareServerTest(Server): # pragma: no cover
Tool(
name="echo_headers",
description="Echo request headers from context",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
),
Tool(
name="echo_context",
description="Echo request context with custom data",
inputSchema={
input_schema={
"type": "object",
"properties": {
"request_id": {"type": "string"},
@ -1553,7 +1553,7 @@ async def test_streamablehttp_request_context_propagation(context_aware_server:
async with ClientSession(read_stream, write_stream) as session: # pragma: no branch
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == "ContextAwareServer"
assert result.server_info.name == "ContextAwareServer"
# Call the tool that echoes headers back
tool_result = await session.call_tool("echo_headers", {})
@ -1619,7 +1619,7 @@ async def test_client_includes_protocol_version_header_after_init(context_aware_
async with ClientSession(read_stream, write_stream) as session:
# Initialize and get the negotiated version
init_result = await session.initialize()
negotiated_version = init_result.protocolVersion
negotiated_version = init_result.protocol_version
# Call a tool that echoes headers to verify the header is present
tool_result = await session.call_tool("echo_headers", {})

View file

@ -68,7 +68,7 @@ class ServerTest(Server): # pragma: no cover
Tool(
name="test_tool",
description="A test tool",
inputSchema={"type": "object", "properties": {}},
input_schema={"type": "object", "properties": {}},
)
]
@ -135,7 +135,7 @@ async def initialized_ws_client_session(server: None, server_url: str) -> AsyncG
# Test initialization
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == SERVER_NAME
assert result.server_info.name == SERVER_NAME
# Test ping
ping_result = await session.send_ping()
@ -153,7 +153,7 @@ async def test_ws_client_basic_connection(server: None, server_url: str) -> None
# Test initialization
result = await session.initialize()
assert isinstance(result, InitializeResult)
assert result.serverInfo.name == SERVER_NAME
assert result.server_info.name == SERVER_NAME
# Test ping
ping_result = await session.send_ping()