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

Support for type annotations? #15

Closed
Muream opened this issue May 9, 2021 · 6 comments
Closed

Support for type annotations? #15

Muream opened this issue May 9, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@Muream
Copy link
Contributor

Muream commented May 9, 2021

I started using type annotations quite a lot these past months and I've grown to love them.

Since none of the Maya APIs are type annotated, every function takes and returns Any. This is really frustrating to work with as you need to explicitly specify the type of a lot of variables when that should be inferred.

I think it would be really nice if cmdc was fully type annotated and made that one of its primary goals.
I haven't looked into how to set that up much so I'm not sure if pybind supports this or if we'd need to also write .pyi stubs for that.

@mottosso
Copy link
Owner

Sounds good to me, either through pybind11 or .pyi. 👍

@mottosso mottosso added the enhancement New feature or request label May 10, 2021
@Muream
Copy link
Contributor Author

Muream commented May 10, 2021

Looks like making .pyi stubs would be the way to go, pyright doesn't support extracting information out of .pyd files
microsoft/pylance-release#70 (comment)

Not yet sure if we'd need to make those manually or somehow generate them though.

I'm also wondering how they should be distributed?

@mottosso
Copy link
Owner

We could distribute any amount and type of files in the Maya module, the install would remain the same. So if .pyi is the way to go, that would work.

@ross-g
Copy link

ross-g commented May 25, 2021

I've used the stubgen tool (part of mypy) to generate .pyi stubs before, but results vary with how thorough the type annotations are. PyCharm will also generate it's own stub files for you in the background which you can repurpose.

Both methods would likely require some manual maintainence to be really useful.

@Muream
Copy link
Contributor Author

Muream commented May 25, 2021

This PR has most of the work done: #16

It uses pybind11-stubgen (which is meant to be merged into stubgen) to generate the stubs from the bindings.
I need to have a deeper look but since we're generating bindings from C++, everything is strongly typed and the generated stubs reflect that well. I'm hoping we'll get away without any manual editing of the stubs.

@Muream
Copy link
Contributor Author

Muream commented Jun 9, 2021

closed by #16

@Muream Muream closed this as completed Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants