Add dunder methods, hidden type discovery, uniform_float override, and docstring fixes
- Introspect dunder methods (__getitem__, __len__, __add__, __matmul__, etc.) on C extension classes with runtime probing for return types - Discover hidden C types from property values (e.g. MatrixAccess from Matrix.col) - Add gpu.types override for uniform_float to accept Matrix, Vector, Euler, Quaternion, and Color (matching Blender's mathutils_array_parse C implementation) - Extend apply_overrides to support ClassName.method_name keys for struct methods - Parse standalone :type: annotations in property docstrings (is_frozen -> bool) - Strip (readonly) and (never None) from docstring type annotations - Add :raises to directive lookahead to prevent rtype bleeding into raises text - Fix NoneType -> None normalization in runtime type probing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+27
-7
@@ -760,18 +760,38 @@ def load_overrides(overrides_dir: str, module_name: str) -> dict[str, ParamOverr
|
||||
return {}
|
||||
|
||||
|
||||
def _apply_func_overrides(
|
||||
func: FunctionData, func_overrides: ParamOverrides
|
||||
) -> None:
|
||||
"""Apply overrides to a single function/method."""
|
||||
param_overrides = func_overrides.get("params", {})
|
||||
for param in func["params"]:
|
||||
if param["name"] in param_overrides:
|
||||
param["type"] = param_overrides[param["name"]]
|
||||
if "return_type" in func_overrides:
|
||||
func["return_type"] = func_overrides["return_type"]
|
||||
|
||||
|
||||
def apply_overrides(
|
||||
module_data: ModuleData, overrides: dict[str, ParamOverrides]
|
||||
) -> ModuleData:
|
||||
"""Apply type overrides to introspected module data."""
|
||||
"""Apply type overrides to introspected module data.
|
||||
|
||||
Keys can be function names (e.g. ``"my_func"``) for module-level functions,
|
||||
or ``"ClassName.method_name"`` for struct methods.
|
||||
"""
|
||||
for func in module_data["functions"]:
|
||||
func_overrides = overrides.get(func["name"], {})
|
||||
param_overrides = func_overrides.get("params", {})
|
||||
for param in func["params"]:
|
||||
if param["name"] in param_overrides:
|
||||
param["type"] = param_overrides[param["name"]]
|
||||
if "return_type" in func_overrides:
|
||||
func["return_type"] = func_overrides["return_type"]
|
||||
if func_overrides:
|
||||
_apply_func_overrides(func, func_overrides)
|
||||
|
||||
for struct in module_data.get("structs", []):
|
||||
for method in struct["methods"]:
|
||||
key = f"{struct['name']}.{method['name']}"
|
||||
method_overrides = overrides.get(key, {})
|
||||
if method_overrides:
|
||||
_apply_func_overrides(method, method_overrides)
|
||||
|
||||
return module_data
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user