π The fast, Pythonic way to build MCP servers and clients.
ty: resolve warnings surfaced by ty 0.0.79 (#5123)
nate nowack73ad4abd1a63
diff --git a/fastmcp_slim/fastmcp/server/lifespan.py b/fastmcp_slim/fastmcp/server/lifespan.pyindex c3cd91695..8cb39a0d2 100644--- a/fastmcp_slim/fastmcp/server/lifespan.py+++ b/fastmcp_slim/fastmcp/server/lifespan.py@@ -44,9 +44,9 @@ To compose with existing `@asynccontextmanager` lifespans, wrap them explicitly:from __future__ import annotations-from collections.abc import AsyncIterator, Callable+from collections.abc import AsyncGenerator, AsyncIterator, Callablefrom contextlib import AbstractAsyncContextManager, asynccontextmanager-from typing import TYPE_CHECKING, Any+from typing import TYPE_CHECKING, Any, castif TYPE_CHECKING:from fastmcp.server.server import FastMCP@@ -84,7 +84,11 @@ class Lifespan:Yields:The lifespan context dict."""- async with asynccontextmanager(self._fn)(server) as result:+ generator_fn = cast(+ Callable[["FastMCP[Any]"], AsyncGenerator[dict[str, Any] | None]],+ self._fn,+ )+ async with asynccontextmanager(generator_fn)(server) as result:yield result if result is not None else {}def __or__(self, other: Lifespan) -> ComposedLifespan:diff --git a/fastmcp_slim/fastmcp/utilities/openapi/schemas.py b/fastmcp_slim/fastmcp/utilities/openapi/schemas.pyindex 872bd10b0..488d6b9bd 100644--- a/fastmcp_slim/fastmcp/utilities/openapi/schemas.py+++ b/fastmcp_slim/fastmcp/utilities/openapi/schemas.py@@ -434,11 +434,7 @@ def _combine_schemas_and_map_params(# Update body_schema with merged propertiesbody_schema["properties"] = merged_propsif merged_required:- # Remove duplicates while preserving order- seen = set()- body_schema["required"] = [- x for x in merged_required if not (x in seen or seen.add(x))- ]+ body_schema["required"] = list(dict.fromkeys(merged_required))# Remove the allOf since we've merged itbody_schema.pop("allOf", None)diff --git a/fastmcp_slim/fastmcp/utilities/types.py b/fastmcp_slim/fastmcp/utilities/types.pyindex ea2024d85..f209b8265 100644--- a/fastmcp_slim/fastmcp/utilities/types.py+++ b/fastmcp_slim/fastmcp/utilities/types.py@@ -274,9 +274,9 @@ class Image:if self.path:# Workaround for WEBP in Py3.10mimetypes.add_type("image/webp", ".webp")- resp = mimetypes.guess_type(self.path, strict=False)- if resp and resp[0] is not None:- return resp[0]+ mime_type, _ = mimetypes.guess_type(self.path, strict=False)+ if mime_type is not None:+ return mime_typereturn "application/octet-stream"return "image/png" # default for raw binary data