mcneel / pythonstubs

Python stubs for .NET assemblies
MIT License
70 stars 13 forks source link

PyStubbler is skipping namespaces and overwriting __init__.pyi #21

Closed tinrobot2000 closed 3 months ago

tinrobot2000 commented 3 months ago

I am using the pystubbler to build the stubs for the Dynamo/Revit assembly ForgeUnitsCLI.dll (Typically located in C:\Program Files\Autodesk\Revit <year>\AddIns\DynamoForRevit directory for Revit versions >= 2023 and also present in the DynamoSandbox root directory) The assembly has three namespaces

image

I am able to generate the stubs by changing line 140 in StubBuilder.cs to i=0 this also avoids overwriting the __init__.pyi file in the root assembly folder

https://github.com/mcneel/pythonstubs/blob/98299771c9ff68157d657596020ed0019f2f3d94/builder/PyStubblerLib/StubBuilder.cs#L140

However I am finding that Pylance is now unable to resolve the Assembly unless I promote the namespace folders to my root autocomplete/stubs folder or adding the ForgeUnitsCLR directory to the python.autoComplete.extraPaths setting. ~I'm not across the Python type hinting syntax so any assistance would be appreciated~ Edit: Reading this -> https://typing.readthedocs.io/en/latest/ Is it possible the identical Assembly and namespace names are causing the bug?

tinrobot2000 commented 3 months ago

I forked the repo and did some refactoring to eliminate the issue. I removed the use of the namespace list by using the keys of the Type dictionary and simplified the creation of child namespaces. Once all the Type stubs are built then ran back through the directory and added the missing __init__.pyi files with the __all__ dunder built from directory listing. Forked repo here -> link