fake-bpy-module
fake-bpy-module copied to clipboard
"type" argument of BlendDataNodeTrees.new() forces incorrect string "DUMMY"
trafficstars
When calling bpy.data.node_groups.new(), you need to specify a node group name and a type name. The valid types can be found by calling it with an invalid type and looking at the error message:
CompositorNodeTree
TextureNodeTree
GeometryNodeTree
ShaderNodeTree
However, the type parameter is typed as Literal['DUMMY'] | None, making it impossible to specify any of these without using # type: ignore.
Ideally, the parameter would be constrained to (just) the valid class names, and the function would return the corresponding class so you can simply do the following:
bl_node_group = bpy.data.node_groups.new("My node group", "GeometryNodeTree")
# bl_node_group is automatically bpy.types.GeometryNodeTree
bl_node_group.is_modifier = True