You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The recursive stubgen is great but with one problem, it generates a pyi file named after the top-level module name even if there are submodules. For instance, if I have a module mylib and it has a submodule lib, it will generate two files (1) mylib.pyi (2) lib/__init__.pyi. The content of mylib.pyi will have the import for lib: from . import lib as lib. This only works when mylib.pyi is within a package (i.e. is under a directory). I could put these two files under a directory "mylib" to make it a package, but it leads to a new problem, this package does not have __init__.py, so importing mylib will not get access to the submodule lib and any top-level classes/functions. The mylib.pyi needs to be renamed to __init__.py.
I think stubgen recursive mode should either always generate the top-level module as a package or at least does that when there are submodules.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
The recursive stubgen is great but with one problem, it generates a pyi file named after the top-level module name even if there are submodules. For instance, if I have a module
mylib
and it has a submodulelib
, it will generate two files (1)mylib.pyi
(2)lib/__init__.pyi
. The content ofmylib.pyi
will have the import forlib
:from . import lib as lib
. This only works whenmylib.pyi
is within a package (i.e. is under a directory). I could put these two files under a directory "mylib" to make it a package, but it leads to a new problem, this package does not have__init__.py
, so importingmylib
will not get access to the submodulelib
and any top-level classes/functions. Themylib.pyi
needs to be renamed to__init__.py
.I think stubgen recursive mode should either always generate the top-level module as a package or at least does that when there are submodules.
Beta Was this translation helpful? Give feedback.
All reactions