fake-bpy-module
fake-bpy-module copied to clipboard
String Enum type should be a union of literal instead of str
Description about the feature
In Blender API, there are enum string type, currently the type used is str | int and ideally should only be str (c.f. #213).
Even better would be that the type is a union of possible literal string variant.
For example the return type of bpy.types.Operator.execute() is
The type would be
Literal["RUNNING_MODAL"] | Literal["CANCELLED"] | Literal["FINISHED"] | Literal["PASS_THROUGH"] | Literal["INTERFACE"].
Are you willing to contribute about this feature. (Yes/No)
Yes
@JonathanPlasse
I assigned this issue to you. Do you have an idea about this? I think this is difficult for our approach to realize this.
If the RST contain the link to the enum page in the return type (e.g. Operator Return Items), it should be feasible.
Otherwise, it will be difficult.
I think it is difficult to parse other RST files while processing the document. If you have an idea, I will remain this issue. Or, I will close this issue. What do you think? @JonathanPlasse
I would like to take a deeper look to implement it.
When encountering an rna enum reference we could parse on the fly the corresponding rst file.
I will see if I can make it work.
Thank you. This needs to support to read related files from somewhere.
I'm wondering this should be done in transformer or analyzer phase. https://github.com/nutti/fake-bpy-module/tree/master/src/fake_bpy_module/analyzer https://github.com/nutti/fake-bpy-module/tree/master/src/fake_bpy_module/transformer
I think adding this feature into the transformer phase is much simpler and easy to maintenance in future.