Jeremiah Lowin commited on
Commit
7a0ee29
·
1 Parent(s): acef890

Match functions and methods

Browse files
src/fastmcp/prompts/prompt.py CHANGED
@@ -112,7 +112,7 @@ class Prompt(BaseModel):
112
  description = description or fn.__doc__
113
 
114
  # if the fn is a callable class, we need to get the __call__ method from here out
115
- if not inspect.isfunction(fn):
116
  fn = fn.__call__
117
 
118
  type_adapter = get_cached_typeadapter(fn)
 
112
  description = description or fn.__doc__
113
 
114
  # if the fn is a callable class, we need to get the __call__ method from here out
115
+ if not inspect.isroutine(fn):
116
  fn = fn.__call__
117
 
118
  type_adapter = get_cached_typeadapter(fn)
src/fastmcp/resources/template.py CHANGED
@@ -150,7 +150,7 @@ class ResourceTemplate(BaseModel):
150
 
151
  description = description or fn.__doc__ or ""
152
 
153
- if not inspect.isfunction(fn):
154
  fn = fn.__call__
155
 
156
  type_adapter = get_cached_typeadapter(fn)
 
150
 
151
  description = description or fn.__doc__ or ""
152
 
153
+ if not inspect.isroutine(fn):
154
  fn = fn.__call__
155
 
156
  type_adapter = get_cached_typeadapter(fn)
src/fastmcp/tools/tool.py CHANGED
@@ -77,7 +77,7 @@ class Tool(BaseModel):
77
  func_doc = description or fn.__doc__ or ""
78
 
79
  # if the fn is a callable class, we need to get the __call__ method from here out
80
- if not inspect.isfunction(fn):
81
  fn = fn.__call__
82
 
83
  type_adapter = get_cached_typeadapter(fn)
 
77
  func_doc = description or fn.__doc__ or ""
78
 
79
  # if the fn is a callable class, we need to get the __call__ method from here out
80
+ if not inspect.isroutine(fn):
81
  fn = fn.__call__
82
 
83
  type_adapter = get_cached_typeadapter(fn)
tests/utilities/test_tests.py CHANGED
@@ -4,6 +4,7 @@ from fastmcp.utilities.tests import temporary_settings
4
 
5
  class TestTemporarySettings:
6
  def test_temporary_settings(self):
7
- with temporary_settings(log_level="DEBUG"):
8
- assert fastmcp.settings.settings.log_level == "DEBUG"
9
- assert fastmcp.settings.settings.log_level == "INFO"
 
 
4
 
5
  class TestTemporarySettings:
6
  def test_temporary_settings(self):
7
+ assert fastmcp.settings.settings.log_level == "DEBUG"
8
+ with temporary_settings(log_level="ERROR"):
9
+ assert fastmcp.settings.settings.log_level == "ERROR"
10
+ assert fastmcp.settings.settings.log_level == "DEBUG"