From db78c031c5d564c5d61660e34bc95fc7bd6df5aa Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Sat, 3 May 2025 08:41:01 +1000 Subject: [PATCH] PyDoc: add types to property doc-strings in bpy.types Also correct type for Object.children_recursive. Ref !138346 --- scripts/modules/bpy_types.py | 44 +++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/scripts/modules/bpy_types.py b/scripts/modules/bpy_types.py index a3aabb8f6b2..30a1adc49aa 100644 --- a/scripts/modules/bpy_types.py +++ b/scripts/modules/bpy_types.py @@ -114,7 +114,15 @@ class Library(_types.ID): @property def users_id(self): - """ID data blocks which use this library""" + """ID data-blocks that use this library + + :type: tuple of :class:`bpy.types.ID` + + .. note:: + + Takes ``O(n)`` time, where ``n`` is the total number of all + linkable ID types in ``bpy.data``. + """ import bpy # See: `readblenentry.cc`, IDTYPE_FLAGS_ISLINKABLE, @@ -139,7 +147,12 @@ class Texture(_types.ID): @property def users_material(self): - """Materials that use this texture""" + """Materials that use this texture + + :type: tuple of :class:`Material` + + .. note:: Takes ``O(len(bpy.data.materials) * len(material.texture_slots))`` time. + """ import bpy return tuple(mat for mat in bpy.data.materials if self in (slot.texture @@ -149,7 +162,12 @@ class Texture(_types.ID): @property def users_object_modifier(self): - """Object modifiers that use this texture""" + """Object modifiers that use this texture + + :type: tuple of :class:`Object` + + .. note:: Takes ``O(len(bpy.data.objects) * len(obj.modifiers))`` time. + """ import bpy return tuple( obj for obj in bpy.data.objects if @@ -165,7 +183,16 @@ class Collection(_types.ID): @property def children_recursive(self): - """A list of all children from this collection.""" + """ + A list of all children from this collection. + + :type: list of :class:`Collection` + + .. note:: + + Takes ``O(n)`` time, where ``n`` is the total number of all + descendant collections. + """ children_recursive = [] def recurse(parent): @@ -178,7 +205,12 @@ class Collection(_types.ID): @property def users_dupli_group(self): - """The collection instance objects this collection is used in""" + """The collection instance objects this collection is used in + + :type: tuple of :class:`Object` + + .. note:: Takes ``O(len(bpy.data.objects))`` time. + """ import bpy return tuple(obj for obj in bpy.data.objects if self == obj.instance_collection) @@ -204,7 +236,7 @@ class Object(_types.ID): """ A list of all children from this object. - :type: tuple of :class:`Object` + :type: list of :class:`Object` .. note:: Takes ``O(len(bpy.data.objects))`` time.""" import bpy