Annotations
Quite possibly this is a dupe of Blender 2.8 - Field property declaration and dynamic class creation
I found that using the type method do define a class in 2.79 was very handy, but for annotations very tricky.
If an __annotations__ is defined on our propertygroup class, can add to it prior to registering.
import bpy
class Test(bpy.types.PropertyGroup):
__annotations__ = {}
for n in range(1, 20):
k = "line_%d" % n
Test.__annotations__[k] = bpy.props.StringProperty(name=k)
bpy.utils.register_class(Test)
bpy.types.Scene.test = bpy.props.PointerProperty(type=Test)
Or in the class
class Test(bpy.types.PropertyGroup):
__annotations__ = {'line_%d' % i: bpy.props.StringProperty(name="line_%d" % i)
for i in range(1, 20)}
Test in py console
>>> C.scene.test.line_1
''