I’m preparing to release Maya 2024 stub files for autocompletion and quick doc display. They are .pyi files meant for Pycharm. Since Autodesk stopped including stub files in the Maya releases, there are several stub file collections available. The difference with mine is that they include ALL documentation. Take a look at an example.
I’ve released Maya stub files since 2008. But I stopped when Autodesk started including their own. Recenlty I dusted off my generator code and updated it. I used to use Highend3D to release the files. But that site is not really stable these days. Does anyone have a suggestion of an easy way to release these that will be easy to access?
I was doing some testing with the Maya API stub files in preparation of putting a release package together. Then I realized something rather surprising which I’d never really appreciated before.
The stub files I put together resulted in only one definition for add(). So I modified the generator to output all the variations. But Pycharm would only recognize one of them. Python does not support function overloading.
However, in the typing module there is the @overload decorator which should provide what is needed. This seems to be what the Python builtins (ie. max()) use under the hood.
But again, Pycharm doesn’t recognize this. This issue has been submitted for Pycharm to improve already more than 4 years ago. Pycharm overload ticket
The last comment was just 2 weeks ago. People consider this issue so important that they are ditching Pycharm for other IDEs.
When I look at other stub files that have been released for Maya, I see that no one has actually dealt with this. I’m wondering how big a deal breaker this is?
pyi files aren’t just for PyCharm. Looks like they are described in multiple PEP’s (I found PEP 484 and PEP 561), so they’re meant to be used by the entire python ecosystem. Anybody using other editors could still benefit from the overloads, and I would absolutely love to have them available.
I use the Neovim text editor with PyRight and MyPy Language Server plugins, but that’s a whole rabbit hole of basically relearning how to edit code. You probably shouldn’t mess with that JUST for testing. There’s a notoriously steep learning curve. I still think everybody should give it a try through! Once you learn it, it’s like magic!
Ok, stepping off the soapbox PyRight is the LS that comes with vscode, so you could definitely test there.
And MyPy is the reference implementation of python static type checking. I was able to easily find a vscode plugin for that.
You may also want to test with Pyre from Facebook, but that seems a bit more involved to set up.
Downloaded VS Code (Pylance) and pointed it to the stub files I have generated. It handles the overloaded methods really nicely.
It provides a nice page flipper widget for the different overloads. And once you have it filled in, it will know to only display the overload that is currently used.
One thing I notice right away though, is the docstring text formatting that Pycharm supports is not supported in VS Code - at least, with default settings. That’s why there’s ** for part of the docstring. That’s supposed to be bolded text.
Awesome work and may I suggest that you join this project: GitHub - LumaPictures/cg-stubs: Python stubs for VFX and Animation ? Would be great to have all the cg stubs we need under one “mother” project (If you want to keep it to yourself, I can totally understand though )
Ah! The project I linked is indeed from Luma pictures but it is not about pymel. Instead it it is about generating stubs for common python libraries from the VFX industry and makes them available on PYPI . For example pip install types-nuke types-mari gives you type hinting for Nuke and Mari. They are still missing maya.cmds, so I think you are pretty much a perfect fit for that project.
But I saw that you are not keen to go on GitHub, which I understand and respect. I will shut up now!
So you don’t just get radio silence: I can say that the vscode style (haven’t tried the others) loads without error for me, and the docstrings show up. But I haven’t been doing maya cmds devopment for the past couple weeks to really put it through its paces.
Though it would be nice if you built stub-only wheels so the type info could be pip-installed. But that’s just mostly me being greedy
Just to say that this is great!
Also python does support overloaded methods in pyi files you just need to mark them with the overload decorator from the typing module: