nutti / fake-bpy-module

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

EnumProperty items does not accept tuples #140

Closed cmbasnett closed 9 months ago

cmbasnett commented 9 months ago

System Information

Expected behavior

The items property in EnumProperty should accept an Iterable of the items (e.g., passing a tuple is valid, but the type hints flags it as an error.

Description about the bug

I have the following:

csg_operation_items = (
    ('CSG_Add', 'Add', 'Add to world', 1),
    ('CSG_Subtract', 'Subtract', 'Subtract from world', 2),
)

And the following usage:

    csg_operation: EnumProperty(
        name='CSG Operation',
        description='The CSG operation to perform when this brush is applied to the world',
        items=csg_operation_items,
        default='CSG_Add',
        update=bsp_brush_update,
        options=empty_set
    )

The error I get is:

Expected type 'list[tuple[str, str, str]] | (...) -> Any | None', got 'tuple[tuple[str, str, str, int], tuple[str, str, str, int]]' instead

Screenshots/Files [Optional]

image

Additional comments [Optional]

In addition, the items themselves can actually have up to 5 elements (id, name, description, icon, num), but the type hinting only expects 3.

nutti commented 9 months ago

This issue is now fixed.