Skip to content

Commit

Permalink
[fix] Resolve submodules using prefix instead of dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
CSRessel committed Mar 11, 2024
1 parent 5297bb9 commit 06dbee4
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ def find_modules_in_package(package_module: ModuleType) -> Iterable[ModuleType]:
yield package_module
package_path = package_module.__file__
if package_path:
for _, modname, is_pkg in pkgutil.walk_packages([os.path.dirname(package_path)]):
submodule = import_module(f"{package_module.__name__}.{modname}")
for _, modname, is_pkg in pkgutil.walk_packages(
package_module.__path__, prefix=package_module.__name__ + "."
):
submodule = import_module(modname)
if is_pkg:
yield from find_modules_in_package(submodule)
else:
Expand Down

0 comments on commit 06dbee4

Please sign in to comment.