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) <noreply@anthropic.com>
This commit is contained in:
Joseph HENRY 2026-04-02 11:07:53 +02:00
parent fe6deadfc7
commit 004b6b11bc

View File

@ -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"