Fix all conformance test failures
- Discover C-level classmethods on RNA types (e.g. Space.draw_handler_add) - Fix getset_descriptor writability detection via __set__ probing - Widen writable mathutils properties to accept Sequence[float] - Widen __setitem__ value to accept parent container type (vec[:] = Vector) - Widen mathutils params (Vector, Euler, etc.) to also accept Sequence[float] - Filter self param from C method_descriptor signatures - Add 5.1 overrides for LocRotScale and Quaternion.__init__ - Comment out memoryview tests (buffer protocol requires Python 3.12+) - Disable reportUnusedExpression and reportUnknownMemberType in conformance Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+42
-2
@@ -1276,7 +1276,7 @@ def _fix_dunder_signatures(
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": f"{vtype} | Sequence[{vtype}]",
|
||||
"type": f"{vtype} | Sequence[{vtype}] | {cls.__name__}",
|
||||
"default": None,
|
||||
"kind": "POSITIONAL_OR_KEYWORD",
|
||||
},
|
||||
@@ -1417,10 +1417,14 @@ def introspect_class(cls: type[object], module_name: str) -> StructData:
|
||||
else:
|
||||
# C getset_descriptors don't expose fset; probe at runtime
|
||||
is_readonly = not _is_getset_writable(cls, name)
|
||||
prop_type = rtype or "object"
|
||||
# Writable properties with mathutils types also accept Sequence[float]
|
||||
if not is_readonly and prop_type in _MATHUTILS_ARRAY_TYPES:
|
||||
prop_type = f"{prop_type} | Sequence[float]"
|
||||
properties.append(
|
||||
{
|
||||
"name": name,
|
||||
"type": rtype or "object",
|
||||
"type": prop_type,
|
||||
"is_readonly": is_readonly,
|
||||
"description": doc,
|
||||
}
|
||||
@@ -2408,6 +2412,42 @@ def introspect_rna_types() -> ModuleData:
|
||||
):
|
||||
structs.append(introspect_class(obj, "bpy.types"))
|
||||
|
||||
# Pick up C-level methods on RNA types that aren't in rna_info
|
||||
# (e.g. Space.draw_handler_add/draw_handler_remove are classmethods
|
||||
# injected at the C level, not RNA functions).
|
||||
for struct in structs:
|
||||
cls = getattr(_bpy_types, struct["name"], None)
|
||||
if cls is None:
|
||||
continue
|
||||
existing = {m["name"] for m in struct["methods"]}
|
||||
existing |= {p["name"] for p in struct["properties"]}
|
||||
for attr_name in sorted(cls.__dict__):
|
||||
if attr_name.startswith("_") or attr_name in existing:
|
||||
continue
|
||||
if attr_name in ("bl_rna", "rna_type"):
|
||||
continue
|
||||
raw = cls.__dict__[attr_name]
|
||||
raw_type = type(raw).__name__
|
||||
# Only pick up C-level methods, not Python-defined ones.
|
||||
# classmethod wrapping a builtin is C-level (e.g. Space.draw_handler_add)
|
||||
is_c_classmethod = raw_type == "classmethod_descriptor" or (
|
||||
isinstance(raw, classmethod)
|
||||
and not hasattr(getattr(raw, "__func__", None), "__code__")
|
||||
)
|
||||
if is_c_classmethod:
|
||||
obj = getattr(cls, attr_name)
|
||||
func_data = introspect_callable(obj, attr_name)
|
||||
if func_data:
|
||||
func_data["is_classmethod"] = True
|
||||
struct["methods"].append(func_data)
|
||||
elif raw_type in (
|
||||
"method_descriptor",
|
||||
"builtin_function_or_method",
|
||||
):
|
||||
func_data = introspect_callable(raw, attr_name)
|
||||
if func_data:
|
||||
struct["methods"].append(func_data)
|
||||
|
||||
return {
|
||||
"module": "bpy.types",
|
||||
"doc": "Blender RNA type definitions.",
|
||||
|
||||
Reference in New Issue
Block a user