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:
2026-03-26 17:18:09 +01:00
co-authored by Claude Opus 4.6
parent b0c2a3a2c1
commit e4739448c2
4 changed files with 296 additions and 11 deletions
+27 -7
View File
@@ -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