MCPcopy Create free account
hub / github.com/LLMQuant/quant-mind / _strip_optional

Function _strip_optional

quantmind/magic.py:152–159  ·  view source on GitHub ↗

Peel ``T | None`` / ``Optional[T]`` to return the inner T.

(anno: Any)

Source from the content-addressed store, hash-verified

150 input_anno = annotations.get("input", sig.parameters["input"].annotation)
151 cfg_anno = annotations.get("cfg", sig.parameters["cfg"].annotation)
152 cfg_type = _strip_optional(cfg_anno)
153 if not (isinstance(cfg_type, type) and issubclass(cfg_type, BaseFlowCfg)):
154 raise TypeError(
155 f"Flow {flow_fn.__name__!r} `cfg` annotation must resolve to "
156 f"a BaseFlowCfg subclass (got {cfg_anno!r})"
157 )
158 return input_anno, cfg_type
159
160
161def _strip_optional(anno: Any) -> Any:
162 """Peel ``T | None`` / ``Optional[T]`` to return the inner T."""

Calls

no outgoing calls

Tested by 4

test_optional_tMethod · 0.72