Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(schema-converter): silence mypy on null-only-anyOf fallback return

venkat82164563486697
diff --git a/python/composio/utils/schema_converter.py b/python/composio/utils/schema_converter.py
index 233c78b0b..b8e341608 100644
--- a/python/composio/utils/schema_converter.py
+++ b/python/composio/utils/schema_converter.py
@@ -234,6 +234,8 @@ def _handle_toplevel_combiner(
allow_undefined_array_items=True,
allow_undefined_type=True,
)
+ if result is type(None):
+ return t.Optional[t.Any]
# If result is a type (like a Union or Optional), return it directly
# If result is a model class, return it
return result
@@ -270,7 +272,7 @@ def _build_union_from_options(options: t.List[t.Dict[str, t.Any]]) -> t.Type:
pydantic_types.append(ptype)
if len(pydantic_types) == 0:
- return str # Fallback
+ return t.Optional[t.Any] if has_null else str # type: ignore
if len(pydantic_types) == 1:
base_type = pydantic_types[0]