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

Function _extract_params

src/ifcedit/ifcedit/discover.py:143–163  ·  view source on GitHub ↗

Extract parameter info from a function's signature and type hints.

(fn)

Source from the content-addressed store, hash-verified

141
142
143def _extract_params(fn) -> list[dict]:
144 """Extract parameter info from a function's signature and type hints."""
145 sig = inspect.signature(fn)
146 try:
147 hints = typing.get_type_hints(fn)
148 except Exception:
149 hints = {}
150
151 params = []
152 for name, param in sig.parameters.items():
153 if name == "file" or name == "self":
154 continue
155 info = {"name": name}
156 if name in hints:
157 info["type"] = _format_type_hint(hints[name])
158 if param.default is not inspect.Parameter.empty:
159 info["default"] = _serialize_default(param.default)
160 else:
161 info["required"] = True
162 params.append(info)
163 return params
164
165
166def _format_type_hint(hint) -> str | None:

Callers 4

_list_shape_methodsFunction · 0.90
_shape_method_docsFunction · 0.90
list_functionsFunction · 0.85
function_docsFunction · 0.85

Calls 4

_format_type_hintFunction · 0.85
_serialize_defaultFunction · 0.85
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected