Skip to content

Commit a466c65

Browse files
committed
fix: use get_origin() for typing.GenericAlias detection
Fixes #3745 by checking the origin of type expressions instead of their class type. typing.Dict[str, Any] is a typing._GenericAlias, not a types.GenericAlias, so the previous check failed to match it. This ensures consistent behavior between typing.Dict and dict annotations, preventing silent schema changes when Ruff UP006 rewrites old-style annotations to modern syntax.
1 parent b68722b commit a466c65

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/mcp/server/mcpserver/utilities/func_metadata.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def _create_output_model(original_annotation: Any, type_expr: Any, func_name: st
500500
wrap_output = True
501501

502502
# Handle GenericAlias types (list[str], dict[str, int], Union[str, int], etc.)
503-
elif isinstance(type_expr, GenericAlias):
503+
elif get_origin(type_expr) is not None:
504504
origin = get_origin(type_expr)
505505

506506
if origin is dict:

0 commit comments

Comments
 (0)