There are two ways into which you can contribute to this:
- Improve the Generated Stubs. See Generating the stubs
- Manually provide signatures for some members.
- Fork and clone the repo
- Do your thing
- Push to your Fork and submit a Pull Request
The project is setup as an uv workspace where:
-
The root package is the actual package for the maya stubs (which are in
src/maya-stubs) The stubs are automatically generated and should not be modified manually. -
the
packagesfolder contains two different packages:maya-stubgen: This is the library that generates the stubscli.pycreates the command line interface for maya-stubgenstubgen.pycontains the functions used to generate the stubsparsers/is where all the different parsers are. A "Parser" is a class that generatesDocspecobjects for a python module
Here are the different parsers:BuiltinParser: "Parses" a builtin module by introspecting it at runtime. This does not give the best results but works on everything. This parser is used as a fallback when other parsers can't be used.MayaParser: Does not actually parse anything but is in charge of calling the best parser for the different maya modulesCmdsParser: Just likeMayaParserit is responsible to call the correct parser for each of the maya commands.CmdsSynopsisParser: parses the result ofcmds.help("MyCommand").
This parser generally will only produce accurate flag types but has the benefit of working for all commands available in the maya session. Including plug-in commands which are not on the HTML docs and generally not included in other stubs.CmdsDocsParser: Parses the html documentation of the maya commands This parser is generally able to get pretty accurate stubs including return types, flag types, docstrings and examples. It is the one used for most commands. Note: There is no dedicated parser for OpenMaya 1.0 and 2.0 yet. These are generated using the BuiltinParser.
docspec-to-jinjawhich is used bymaya-stubgento generate the stubs content from the docspec objects.
- uv
- Maya 2023 or above
- (Optional) Set the environment variable
MAYA_LOCATIONto the maya install dir of the version you want to generate the stubs for.- Windows:
C:\Program Files\Autodesk\Maya2026 - macOS:
/Applications/Autodesk/maya2026 - Linux:
/usr/autodesk/maya2026 - If
MAYA_LOCATIONis not set, the tool will automatically search for Maya installations in the default platform-specific locations, preferring the newest version found (current year + 2 down to Maya 2023).
- Windows:
- Generate the stubs with
uv run maya-stubgen generate-stubs src/. - After the first run, you can re-use the docspec cache with
uv run maya-stubgen generate-stubs src/ --reuse-cache. This is useful if you're not making any changes to the parsers but only to the code generation side of things. - You can generate stubs for specific modules or members by specifying the
-m/--moduleand/or--membersoptions:This will only create stubs for theuv run maya-stubgen generate-stubs src/ -m maya.cmds --members "(currentTime|playblast)$"currentTimeandplayblastPython commands; useful for quickly testing changes.