Clean/Fix remaining cases of props assignments in resgistrable structs def.
We still had a few deprecated assignements of `bpy.props.xxx` to class members in our API documentation and one of our py tests. Annotations are to be used now. Also remove the section about `register_module` utils, this has been removed in 2.8. Fix T71877: Python API overview sample code warning: class MyMaterialProps contains a property which should be an annotation! Fix T71876: Python API overview references old bpy.utils.register_module function
This commit is contained in:
@@ -54,8 +54,8 @@ def abort_if_false(expr, msg=None):
|
||||
|
||||
|
||||
class TestClass(bpy.types.PropertyGroup):
|
||||
test_prop = bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
name = bpy.props.StringProperty()
|
||||
test_prop: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
name: bpy.props.StringProperty()
|
||||
|
||||
|
||||
def get_scene(lib_name, sce_name):
|
||||
@@ -213,13 +213,14 @@ def test_restrictions1():
|
||||
bl_idname = 'scene.test_op'
|
||||
bl_label = 'Test'
|
||||
bl_options = {"INTERNAL"}
|
||||
str_prop = bpy.props.StringProperty(name="str_prop")
|
||||
|
||||
str_prop: bpy.props.StringProperty(name="str_prop")
|
||||
|
||||
# disallow registration of datablock properties in operators
|
||||
# will be checked in the draw method (test manually)
|
||||
# also, see console:
|
||||
# ValueError: bpy_struct "SCENE_OT_test_op" doesn't support datablock properties
|
||||
id_prop = bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
id_prop: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
|
||||
def execute(self, context):
|
||||
return {'FINISHED'}
|
||||
@@ -291,7 +292,7 @@ def test_regressions():
|
||||
# test restrictions for datablock pointers
|
||||
def test_restrictions2():
|
||||
class TestClassCollection(bpy.types.PropertyGroup):
|
||||
prop = bpy.props.CollectionProperty(
|
||||
prop: bpy.props.CollectionProperty(
|
||||
name="prop_array",
|
||||
type=TestClass)
|
||||
bpy.utils.register_class(TestClassCollection)
|
||||
@@ -299,9 +300,9 @@ def test_restrictions2():
|
||||
class TestPrefs(bpy.types.AddonPreferences):
|
||||
bl_idname = "testprefs"
|
||||
# expecting crash during registering
|
||||
my_prop2 = bpy.props.PointerProperty(type=TestClass)
|
||||
my_prop2: bpy.props.PointerProperty(type=TestClass)
|
||||
|
||||
prop = bpy.props.PointerProperty(
|
||||
prop: bpy.props.PointerProperty(
|
||||
name="prop",
|
||||
type=TestClassCollection,
|
||||
description="test")
|
||||
@@ -309,7 +310,7 @@ def test_restrictions2():
|
||||
bpy.types.Addon.a = bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
|
||||
class TestUIList(UIList):
|
||||
test = bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
test: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||
layout.prop(item, "name", text="", emboss=False, icon_value=icon)
|
||||
|
Reference in New Issue
Block a user