Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Enum type should be a union of literal instead of str #216

Open
JonathanPlasse opened this issue May 15, 2024 · 6 comments
Open

String Enum type should be a union of literal instead of str #216

JonathanPlasse opened this issue May 15, 2024 · 6 comments
Assignees

Comments

@JonathanPlasse
Copy link
Sponsor Contributor

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
Screenshot from 2024-05-15 23-00-24
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

@nutti
Copy link
Owner

nutti commented May 27, 2024

@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.

@JonathanPlasse
Copy link
Sponsor Contributor Author

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.

image

@nutti
Copy link
Owner

nutti commented May 27, 2024

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

@JonathanPlasse
Copy link
Sponsor Contributor Author

I would like to take a deeper look to implement it.

@JonathanPlasse
Copy link
Sponsor Contributor Author

When encountering an rna enum reference we could parse on the fly the corresponding rst file.
Screenshot from 2024-06-03 21-51-08
Screenshot from 2024-06-03 21-51-40

I will see if I can make it work.

@nutti
Copy link
Owner

nutti commented Jun 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants