Match functions and methods

This commit is contained in:
Jeremiah Lowin 2025-05-23 19:00:54 -04:00
commit 794ef3f114
4 changed files with 7 additions and 6 deletions

View file

@ -112,7 +112,7 @@ class Prompt(BaseModel):
description = description or fn.__doc__
# if the fn is a callable class, we need to get the __call__ method from here out
if not inspect.isfunction(fn):
if not inspect.isroutine(fn):
fn = fn.__call__
type_adapter = get_cached_typeadapter(fn)

View file

@ -150,7 +150,7 @@ class ResourceTemplate(BaseModel):
description = description or fn.__doc__ or ""
if not inspect.isfunction(fn):
if not inspect.isroutine(fn):
fn = fn.__call__
type_adapter = get_cached_typeadapter(fn)

View file

@ -77,7 +77,7 @@ class Tool(BaseModel):
func_doc = description or fn.__doc__ or ""
# if the fn is a callable class, we need to get the __call__ method from here out
if not inspect.isfunction(fn):
if not inspect.isroutine(fn):
fn = fn.__call__
type_adapter = get_cached_typeadapter(fn)

View file

@ -4,6 +4,7 @@ from fastmcp.utilities.tests import temporary_settings
class TestTemporarySettings:
def test_temporary_settings(self):
with temporary_settings(log_level="DEBUG"):
assert fastmcp.settings.settings.log_level == "DEBUG"
assert fastmcp.settings.settings.log_level == "INFO"
assert fastmcp.settings.settings.log_level == "DEBUG"
with temporary_settings(log_level="ERROR"):
assert fastmcp.settings.settings.log_level == "ERROR"
assert fastmcp.settings.settings.log_level == "DEBUG"