Skip to content

Commit fa5ebd7

Browse files
authored
Merge pull request #57 from jurasofish/Avoid-new-try_eval_type-unavailable-on-older-pydantic
Avoid new try_eval_type unavailable with older pydantic
2 parents 8518816 + 2c89684 commit fa5ebd7

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/fastmcp/utilities/func_metadata.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99
from pydantic import Field
1010
from fastmcp.exceptions import InvalidSignature
11-
from pydantic._internal._typing_extra import try_eval_type
11+
from pydantic._internal._typing_extra import eval_type_lenient
1212
import json
1313
from pydantic import BaseModel
1414
from pydantic.fields import FieldInfo
@@ -178,12 +178,7 @@ def func_metadata(func: Callable, skip_names: Sequence[str] = ()) -> FuncMetadat
178178
def _get_typed_annotation(annotation: Any, globalns: Dict[str, Any]) -> Any:
179179
if isinstance(annotation, str):
180180
annotation = ForwardRef(annotation)
181-
annotation, status = try_eval_type(annotation, globalns, globalns)
182-
183-
# This check and raise could perhaps be skipped, and we (FastMCP) just call
184-
# model_rebuild right before using it 🤷
185-
if status is False:
186-
raise InvalidSignature(f"Unable to evaluate type annotation {annotation}")
181+
annotation = eval_type_lenient(annotation, globalns, globalns)
187182

188183
return annotation
189184

0 commit comments

Comments
 (0)