Muream / maya-stubs

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

Improve annotations for commands that actually returns an Optional type #13

Open Muream opened 1 year ago

Muream commented 1 year ago

A good example of this issue is listConnections which is currently stubbed as follows:

def listConnections(*args: str, [...]) -> List[str]:

Instead of this:

def listConnections(*args: str, [...]) -> Optional[List[str]]:

Which leads to people writing this

connections = cmds.listConnections("myNode.myAttr")

for connection in connections:  # should warn that `"None" is not iterable`
    ...

Instead of this:

connections = cmds.listConnections("myNode.myAttr") or []

for connection in connections:
    ...

Neither the docs or the synopsis have that information though so this might need stub In which case, this depends on #12