mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Fix static analysis with latest ty (#4739)
* Fix upgrade static analysis Generated with Codex * Preserve concrete transport return types Generated with Codex * Avoid widening transport return types Generated with Codex * Model transforming transport return types Generated with Codex * Exclude standalone screenshot examples from ty Generated with Codex
This commit is contained in:
parent
022547ad8c
commit
a7e9b70919
3 changed files with 11 additions and 7 deletions
|
|
@ -45,6 +45,7 @@ from fastmcp import _install_hints
|
|||
if 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 StdioTransport
|
||||
|
||||
return 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,
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class InMemoryStdioMCPServer(StdioMCPServer):
|
|||
mcp: FastMCP
|
||||
command: str = "in-memory"
|
||||
|
||||
def to_transport(self) -> FastMCPTransport: # ty: ignore[invalid-method-override]
|
||||
def to_transport(self) -> FastMCPTransport:
|
||||
return FastMCPTransport(mcp=self.mcp)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue