Fix ty diagnostics in tests for SDK v2 migration

This commit is contained in:
Jeremiah Lowin 2026-07-06 00:48:03 -04:00
commit ea9a1c6382
No known key found for this signature in database
4 changed files with 8 additions and 7 deletions

View file

@ -12,7 +12,7 @@ from enum import Enum as PyEnum
import mcp_types
from mcp_types import EmbeddedResource, ImageContent, TextContent
from pydantic import AnyUrl, BaseModel, Field
from pydantic import BaseModel, Field
from fastmcp import FastMCP
from fastmcp.exceptions import ToolError
@ -77,7 +77,7 @@ async def test_embedded_resource() -> list:
EmbeddedResource(
type="resource",
resource=mcp_types.TextResourceContents(
uri=AnyUrl("test://embedded-resource"),
uri="test://embedded-resource",
mime_type="text/plain",
text="This is an embedded resource content.",
),
@ -98,7 +98,7 @@ async def test_multiple_content_types() -> list:
EmbeddedResource(
type="resource",
resource=mcp_types.TextResourceContents(
uri=AnyUrl("test://mixed-content-resource"),
uri="test://mixed-content-resource",
mime_type="application/json",
text='{"test":"data","value":123}',
),
@ -348,7 +348,7 @@ async def test_prompt_with_embedded_resource(resourceUri: str) -> list:
EmbeddedResource(
type="resource",
resource=mcp_types.TextResourceContents(
uri=AnyUrl(resourceUri),
uri=resourceUri,
mime_type="text/plain",
text=f"Content of resource {resourceUri}",
),

View file

@ -108,6 +108,7 @@ class TestResourceURLValidation:
await proxy_with_resource_url.authorize(client, params)
assert exc_info.value.error == "invalid_target"
assert exc_info.value.error_description is not None
assert "Resource does not match" in exc_info.value.error_description
async def test_authorize_accepts_matching_resource(self, proxy_with_resource_url):

View file

@ -83,7 +83,7 @@ async def test_task_tool_invalid_arguments_fail_before_task_state():
self.methods: list[str] = []
async def on_notification(self, message: mcp_types.ServerNotification) -> None:
self.methods.append(message.root.method)
self.methods.append(message.method)
server = FastMCP("tool-task-invalid-args-server")

View file

@ -8,7 +8,6 @@ import sys
import tempfile
import time
from collections.abc import AsyncGenerator
from datetime import timedelta
from pathlib import Path
from typing import Any
from unittest.mock import AsyncMock, patch
@ -961,7 +960,8 @@ async def test_multi_server_timeout_propagation():
)
transport = MCPConfigTransport(config)
timeout = timedelta(seconds=42)
# SDK v2: read_timeout_seconds is a plain number of seconds, not a timedelta.
timeout = 42.0
# Mock _create_proxy to avoid real stdio connections and verify timeout
mock_create_proxy = AsyncMock(