Skip to content

Update: add __iter__ for IDPropertyGroupView classes #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2025

Conversation

Andrej730
Copy link
Contributor

PR solves issues with an example below:

import bpy

class MyPropertyGroup(bpy.types.PropertyGroup):
    custom_1: bpy.props.FloatProperty(name="My Float")
    custom_2: bpy.props.IntProperty(name="My Int")

bpy.utils.register_class(MyPropertyGroup)

bpy.types.Object.my_prop_grp = bpy.props.PointerProperty(type=MyPropertyGroup)

props: MyPropertyGroup = bpy.data.objects[0].my_prop_grp
props.custom_1 = 22.0
print(a:=list(props.keys()))
print(b:=list(props.values()))
print(c:=list(props.items()))
print(c:=list(props.items()))

Diff for fake bpy modules after PR:

diff --git a/build_files/idprop/types/__init__.pyi b/build_files/idprop/types/__init__.pyi
index 7ab9575..557abce 100644
--- a/build_files/idprop/types/__init__.pyi
+++ b/build_files/idprop/types/__init__.pyi
@@ -55,6 +55,6 @@ class IDPropertyGroup:
 class IDPropertyGroupIterItems: ...
 class IDPropertyGroupIterKeys: ...
 class IDPropertyGroupIterValues: ...
-class IDPropertyGroupViewItems: ...
-class IDPropertyGroupViewKeys: ...
-class IDPropertyGroupViewValues: ...
+class IDPropertyGroupViewItems(collections.abc.Iterable[tuple[str, typing.Any]]): ...
+class IDPropertyGroupViewKeys(collections.abc.Iterable[str]): ...
+class IDPropertyGroupViewValues(collections.abc.Iterable[typing.Any]): ...

PR solves issues with an example below:
```python
import bpy

class MyPropertyGroup(bpy.types.PropertyGroup):
    custom_1: bpy.props.FloatProperty(name="My Float")
    custom_2: bpy.props.IntProperty(name="My Int")

bpy.utils.register_class(MyPropertyGroup)

bpy.types.Object.my_prop_grp = bpy.props.PointerProperty(type=MyPropertyGroup)

props: MyPropertyGroup = bpy.data.objects[0].my_prop_grp
props.custom_1 = 22.0
print(a:=list(props.keys()))
print(b:=list(props.values()))
print(c:=list(props.items()))
print(c:=list(props.items()))
```

Diff for fake bpy modules after PR:
```diff
diff --git a/build_files/idprop/types/__init__.pyi b/build_files/idprop/types/__init__.pyi
index 7ab9575..557abce 100644
--- a/build_files/idprop/types/__init__.pyi
+++ b/build_files/idprop/types/__init__.pyi
@@ -55,6 +55,6 @@ class IDPropertyGroup:
 class IDPropertyGroupIterItems: ...
 class IDPropertyGroupIterKeys: ...
 class IDPropertyGroupIterValues: ...
-class IDPropertyGroupViewItems: ...
-class IDPropertyGroupViewKeys: ...
-class IDPropertyGroupViewValues: ...
+class IDPropertyGroupViewItems(collections.abc.Iterable[tuple[str, typing.Any]]): ...
+class IDPropertyGroupViewKeys(collections.abc.Iterable[str]): ...
+class IDPropertyGroupViewValues(collections.abc.Iterable[typing.Any]): ...
```
@nutti nutti merged commit d34ed25 into nutti:main Apr 21, 2025
40 of 47 checks passed
@nutti
Copy link
Owner

nutti commented Apr 21, 2025

Thank you.

@Andrej730 Andrej730 deleted the fix_id_property_group_view branch April 21, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants