From cad1ebadd9ff1c062ad45ad8664e9fc8540c6ce1 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Wed, 4 Jun 2025 16:01:24 -0400 Subject: [PATCH] Ensure deprecation warnings have stacklevel=2 --- src/fastmcp/prompts/prompt_manager.py | 1 + src/fastmcp/resources/resource_manager.py | 2 ++ src/fastmcp/tools/tool_manager.py | 1 + 3 files changed, 4 insertions(+) diff --git a/src/fastmcp/prompts/prompt_manager.py b/src/fastmcp/prompts/prompt_manager.py index 47076e7c6..fea5ebcd4 100644 --- a/src/fastmcp/prompts/prompt_manager.py +++ b/src/fastmcp/prompts/prompt_manager.py @@ -60,6 +60,7 @@ class PromptManager: warnings.warn( "PromptManager.add_prompt_from_fn() is deprecated. Use Prompt.from_function() and call add_prompt() instead.", DeprecationWarning, + stacklevel=2, ) prompt = FunctionPrompt.from_function( fn, name=name, description=description, tags=tags diff --git a/src/fastmcp/resources/resource_manager.py b/src/fastmcp/resources/resource_manager.py index 33731d065..b802d7d8c 100644 --- a/src/fastmcp/resources/resource_manager.py +++ b/src/fastmcp/resources/resource_manager.py @@ -125,6 +125,7 @@ class ResourceManager: warnings.warn( "add_resource_from_fn is deprecated. Use Resource.from_function() and call add_resource() instead.", DeprecationWarning, + stacklevel=2, ) resource = Resource.from_function( fn=fn, @@ -181,6 +182,7 @@ class ResourceManager: warnings.warn( "add_template_from_fn is deprecated. Use ResourceTemplate.from_function() and call add_template() instead.", DeprecationWarning, + stacklevel=2, ) template = ResourceTemplate.from_function( fn, diff --git a/src/fastmcp/tools/tool_manager.py b/src/fastmcp/tools/tool_manager.py index 4ac72c78f..a05701a17 100644 --- a/src/fastmcp/tools/tool_manager.py +++ b/src/fastmcp/tools/tool_manager.py @@ -73,6 +73,7 @@ class ToolManager: warnings.warn( "ToolManager.add_tool_from_fn() is deprecated. Use Tool.from_function() and call add_tool() instead.", DeprecationWarning, + stacklevel=2, ) tool = Tool.from_function( fn,