Closed JonathanPlasse closed 2 months ago
Should I create a new node to use the PEP 695 type
syntax instead?
Should I create a new node to use the PEP 695
type
syntax instead?
Could you show me the mock generated code? To solve #161, it seems necessary to do this.
It would be nice if we could put OperatorReturnItems
in some other module and not to bpy.types
to emphasize that Blender doesn't have it originally. Maybe bpy.typing
?
The CI was failing because the type
syntax is Python 3.12+ only.
I move the enum literal types to bpy.typing
like suggested.
Enum type must be imported with from bpy.typing import <EnumItemType>
as typing
is not present in bpy.__init__.py
.
Here is a snapshot of the generated code of bpy.typing
.
Purpose of the pull request
This PR adds type aliases for the literals that contain the enum items. Using the type aliases avoid having to manually add the different literal values.
Before
After
Note that the type aliases are only available in the pyi files and not during runtime, so we must use forward reference when using them (i.e. use quotes around the type).
It also allows for auto-completion.
Description about the pull request
DefaultValueNode
has been added toDataNode
andAttributeNode
to store the value of the type alias. The tests fixtures have been updated accordingly.get_rna_enum_items()
adds the type aliases to the document and refine the type to the type alias.