Coerce JSON-parsed kwargs to proper Python types for a ShapeBuilder method.
(fn: Callable, raw_kwargs: dict, model: ifcopenshell.file)
| 137 | |
| 138 | |
| 139 | def _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 | |
| 157 | def _coerce_shape_value(value: Any, hint: Any, model: ifcopenshell.file) -> Any: |
no test coverage detected