nutti / fake-bpy-module

Fake Blender Python API module collection for the code completion.
MIT License
1.37k stars 97 forks source link

bpy.props doesn't seem to actually accept positional arguments #226

Closed Andrej730 closed 4 months ago

Andrej730 commented 4 months ago

Using fake-bpy-module-latest-20240522.

Consider example at the end of the post, all those properties have name as their first argument and from .pyi it seems that this argument is positional but after running the snippet below Blender outputs default property names, name argument didn't worked. But if we provide name as a keyword argument, it will work. image

So it seems those props arguments are kind of keyword only. Maybe they should be defined as keyword only? Though no idea what's the first positional argument is then if it's not name - I guess it's still there since there was no error defining a property with just 1 positional argument.

def BoolProperty(
    *,
    name: str | None = "",
    description: str | None = "",

Example:

import bpy

bpy.types.Scene.BoolProperty = bpy.props.BoolProperty("prop name")
bpy.types.Scene.BoolVectorProperty = bpy.props.BoolVectorProperty("prop name")
bpy.types.Scene.FloatProperty = bpy.props.FloatProperty("prop name")
bpy.types.Scene.FloatVectorProperty = bpy.props.FloatVectorProperty("prop name")
bpy.types.Scene.IntProperty = bpy.props.IntProperty("prop name")
bpy.types.Scene.IntVectorProperty = bpy.props.IntVectorProperty("prop name")
bpy.types.Scene.StringProperty = bpy.props.StringProperty("prop name")

# BoolProperty
# BoolVectorProperty
# FloatProperty
# FloatVectorProperty
# IntProperty
# IntVectorProperty
# StringProperty
print(bpy.context.scene.bl_rna.properties["BoolProperty"].name)
print(bpy.context.scene.bl_rna.properties["BoolVectorProperty"].name)
print(bpy.context.scene.bl_rna.properties["FloatProperty"].name)
print(bpy.context.scene.bl_rna.properties["FloatVectorProperty"].name)
print(bpy.context.scene.bl_rna.properties["IntProperty"].name)
print(bpy.context.scene.bl_rna.properties["IntVectorProperty"].name)
print(bpy.context.scene.bl_rna.properties["StringProperty"].name)

bpy.types.Scene.BoolProperty = bpy.props.BoolProperty(name="prop name")
bpy.types.Scene.BoolVectorProperty = bpy.props.BoolVectorProperty(name="prop name")
bpy.types.Scene.FloatProperty = bpy.props.FloatProperty(name="prop name")
bpy.types.Scene.FloatVectorProperty = bpy.props.FloatVectorProperty(name="prop name")
bpy.types.Scene.IntProperty = bpy.props.IntProperty(name="prop name")
bpy.types.Scene.IntVectorProperty = bpy.props.IntVectorProperty(name="prop name")
bpy.types.Scene.StringProperty = bpy.props.StringProperty(name="prop name")

# prop name
# prop name
# prop name
# prop name
# prop name
# prop name
# prop name
print(bpy.context.scene.bl_rna.properties["BoolProperty"].name)
print(bpy.context.scene.bl_rna.properties["BoolVectorProperty"].name)
print(bpy.context.scene.bl_rna.properties["FloatProperty"].name)
print(bpy.context.scene.bl_rna.properties["FloatVectorProperty"].name)
print(bpy.context.scene.bl_rna.properties["IntProperty"].name)
print(bpy.context.scene.bl_rna.properties["IntVectorProperty"].name)
print(bpy.context.scene.bl_rna.properties["StringProperty"].name)
nutti commented 4 months ago

This issue is now fixed.