Muream / maya-stubs

Stubs for Autodesk Maya
MIT License
40 stars 4 forks source link

support for MDagPath in *args type signatures #15

Closed mdilena closed 5 months ago

mdilena commented 1 year ago

It looks like a lot of commands can accept a MDagPath other than a string, at least when it comes to Python API 2.0, so it could be nice to have something like: *args: Union[str, maya.api.OpenMaya.MDagPath] So far it's been pretty consistent with most commands that accept a node's name, but maybe it gets more complex to handle for commands that deal with attributes.

Muream commented 1 year ago

Oh I didn't even know that was possible! The docs tend to specify when the string is meant to be an attribute vs an node, though I have a feeling there's gonna be a lot of edge cases in how that distinction is made in the docs

mdilena commented 1 year ago

Yeah it was a completely random discovery 🙂 I wonder if something simple that catches a few cases could be the solution here, since args is always vague anyway: `args: Union[str, maya.api.OpenMaya.MDagPath, List[str], List[float], List[int]]` as different commands to different things (setAttr/getAttr are one example of multiple args).

I mean, these are nuances...I just started using strict typing in vscode and it's marking those cases as an error, but in the end even just with typed - and long named 🙏 - keyword arguments it's so much better already.

Muream commented 1 year ago

Yeah, I guess it wouldn't really hurt much to have more permissive annotations for *args even if that leads to some inaccuracies My goal for now is to have mostly accurate stubs that make it enjoyable to use cmds in a strictly typed environment and then refine more and more down the line to tend towards 100% type accurate stubs. Hopefully maya's long gone before I get there haha

mdilena commented 5 months ago

Just closing this as it's not really necessary I realize :slightly_smiling_face: