MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / _coerce_shape_params

Function _coerce_shape_params

src/ifcmcp/ifcmcp/core.py:139–154  ·  view source on GitHub ↗

Coerce JSON-parsed kwargs to proper Python types for a ShapeBuilder method.

(fn: Callable, raw_kwargs: dict, model: ifcopenshell.file)

Source from the content-addressed store, hash-verified

137
138
139def _coerce_shape_params(fn: Callable, raw_kwargs: dict, model: ifcopenshell.file) -> dict:
140 """Coerce JSON-parsed kwargs to proper Python types for a ShapeBuilder method."""
141 import inspect
142 import typing
143
144 sig = inspect.signature(fn)
145 try:
146 hints = typing.get_type_hints(fn)
147 except Exception:
148 hints = {}
149
150 return {
151 key: _coerce_shape_value(value, hints.get(key), model)
152 for key, value in raw_kwargs.items()
153 if key in sig.parameters and key != "self"
154 }
155
156
157def _coerce_shape_value(value: Any, hint: Any, model: ifcopenshell.file) -> Any:

Callers 1

ifc_shapeMethod · 0.85

Calls 3

_coerce_shape_valueFunction · 0.85
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected