From 004b6b11bcccc8442c006afa6891a98fd21cc584 Mon Sep 17 00:00:00 2001 From: Joseph HENRY Date: Thu, 2 Apr 2026 11:07:53 +0200 Subject: [PATCH] Fix Context.property type to tuple[bpy_struct, str, int] bpy.context.property returns (data_block, data_path, array_index) where the data_block is a bpy_struct that supports keyframe_insert etc. Co-Authored-By: Claude Opus 4.6 (1M context) --- introspect.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/introspect.py b/introspect.py index 2b5f76b..748660f 100644 --- a/introspect.py +++ b/introspect.py @@ -74,7 +74,7 @@ SCREEN_CONTEXT_TYPE_OVERRIDES: dict[str, str] = { "objects_in_mode_unique_data": "Sequence[Object]", "particle_edit_object": "Object", "pose_object": "Object", - "property": "str", + "property": "tuple[bpy_struct, str, int]", "sculpt_object": "Object", "selectable_objects": "Sequence[Object]", "selected_bones": "Sequence[EditBone]", @@ -1307,9 +1307,24 @@ def _fix_dunder_signatures( method["params"] = [] if method["name"] == "__exit__": method["params"] = [ - {"name": "exc_type", "type": "type[BaseException] | None", "default": None, "kind": "POSITIONAL_OR_KEYWORD"}, - {"name": "exc_val", "type": "BaseException | None", "default": None, "kind": "POSITIONAL_OR_KEYWORD"}, - {"name": "exc_tb", "type": "object", "default": None, "kind": "POSITIONAL_OR_KEYWORD"}, + { + "name": "exc_type", + "type": "type[BaseException] | None", + "default": None, + "kind": "POSITIONAL_OR_KEYWORD", + }, + { + "name": "exc_val", + "type": "BaseException | None", + "default": None, + "kind": "POSITIONAL_OR_KEYWORD", + }, + { + "name": "exc_tb", + "type": "object", + "default": None, + "kind": "POSITIONAL_OR_KEYWORD", + }, ] if method["name"] == "__delitem__": method["params"] = [ @@ -2135,15 +2150,23 @@ def rna_property_to_type(prop: object) -> str: # Fixed-length float arrays with vector/matrix subtypes are mathutils types subtype: str = getattr(prop, "subtype", "NONE") if prop_type == "float" and subtype in ( - "TRANSLATION", "DIRECTION", "VELOCITY", "ACCELERATION", - "XYZ", "XYZ_LENGTH", + "TRANSLATION", + "DIRECTION", + "VELOCITY", + "ACCELERATION", + "XYZ", + "XYZ_LENGTH", ): return "mathutils.Vector" if prop_type == "float" and subtype == "EULER": return "mathutils.Euler" if prop_type == "float" and subtype == "QUATERNION": return "mathutils.Quaternion" - if prop_type == "float" and subtype in ("COLOR", "COLOR_GAMMA") and array_length == 3: + if ( + prop_type == "float" + and subtype in ("COLOR", "COLOR_GAMMA") + and array_length == 3 + ): return "mathutils.Color" if prop_type == "float" and subtype == "MATRIX": return "mathutils.Matrix"