π The fast, Pythonic way to build MCP servers and clients.
Fix static analysis with latest ty (#4739)
nate nowacka7e9b709192d
diff --git a/fastmcp_slim/fastmcp/mcp_config.py b/fastmcp_slim/fastmcp/mcp_config.pyindex c09d9f3c6..b18ea1a3e 100644--- a/fastmcp_slim/fastmcp/mcp_config.py+++ b/fastmcp_slim/fastmcp/mcp_config.py@@ -45,6 +45,7 @@ from fastmcp import _install_hintsif TYPE_CHECKING:from fastmcp.client.transports import (ClientTransport,+ FastMCPTransport,SSETransport,StdioTransport,StreamableHttpTransport,@@ -153,7 +154,7 @@ class _TransformingMCPServerMixin(BaseModel):return wrapped_mcp_server, transport- def to_transport(self) -> ClientTransport:+ def to_transport(self) -> FastMCPTransport:"""Get the transport for the transforming MCP server."""try:from fastmcp.client.transports import FastMCPTransport@@ -209,7 +210,7 @@ class StdioMCPServer(BaseModel):model_config = ConfigDict(extra="allow") # Preserve unknown fields- def to_transport(self) -> StdioTransport:+ def to_transport(self) -> StdioTransport | FastMCPTransport:from fastmcp.client.transports import StdioTransportreturn StdioTransport(@@ -261,7 +262,9 @@ class RemoteMCPServer(BaseModel):extra="allow", arbitrary_types_allowed=True) # Preserve unknown fields- def to_transport(self) -> StreamableHttpTransport | SSETransport:+ def to_transport(+ self,+ ) -> StreamableHttpTransport | SSETransport | FastMCPTransport:from fastmcp.client.transports import (SSETransport,StreamableHttpTransport,diff --git a/pyproject.toml b/pyproject.tomlindex 005194822..27b3596b0 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -157,6 +157,8 @@ exclude = ["examples/smart_home", # needs phue"examples/apps/qr_server", # needs qrcode"examples/providers/sqlite", # needs aiosqlite+ "examples/fastmcp_config_demo", # needs pyautogui, Pillow+ "examples/screenshot.py", # needs pyautogui, Pillow"examples/memory.py", # needs asyncpg, numpy, pydantic_ai, pgvector"examples/get_file.py", # needs aiohttp]@@ -165,9 +167,8 @@ exclude = [python-version = "3.10"[tool.ty.analysis]-# prefab_ui is the apps SDK; pyautogui/PIL are optional runtime deps used only-# inside example tool bodies (screenshot demos) and are not installed here.-replace-imports-with-any = ["prefab_ui.**", "pyautogui", "PIL", "PIL.**"]+# prefab_ui is the apps SDK and is not installed here.+replace-imports-with-any = ["prefab_ui.**"][tool.ty.rules]division-by-zero = "warn"diff --git a/tests/test_mcp_config.py b/tests/test_mcp_config.pyindex a35af2287..93d673e61 100644--- a/tests/test_mcp_config.py+++ b/tests/test_mcp_config.py@@ -96,7 +96,7 @@ class InMemoryStdioMCPServer(StdioMCPServer):mcp: FastMCPcommand: str = "in-memory"- def to_transport(self) -> FastMCPTransport: # ty: ignore[invalid-method-override]+ def to_transport(self) -> FastMCPTransport:return FastMCPTransport(mcp=self.mcp)