MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _strip_optional

Function _strip_optional

utils/function_catalog.py:240–246  ·  view source on GitHub ↗
(annotation: Any)

Source from the content-addressed store, hash-verified

238
239
240def _strip_optional(annotation: Any) -> Tuple[Any, bool]:
241 origin = get_origin(annotation)
242 if origin is Union:
243 args = [arg for arg in get_args(annotation) if arg is not type(None)] # noqa: E721
244 if len(args) == 1 and len(args) != len(get_args(annotation)):
245 return args[0], True
246 return annotation, False
247
248
249def _annotation_to_schema(annotation: Any) -> Dict[str, Any]:

Callers 1

_build_parameters_schemaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected