Skip to content

Commit

Permalink
Fix package import verification (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout authored Jul 19, 2021
1 parent a390189 commit 9356ef8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/dipdup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import types
from contextlib import asynccontextmanager
from logging import Logger
from os.path import dirname
from typing import Any, AsyncIterator, Dict, Iterator, List, Optional, Tuple, Type

import humps # type: ignore
Expand All @@ -24,10 +23,9 @@

def import_submodules(package: str) -> Dict[str, types.ModuleType]:
"""Import all submodules of a module, recursively, including subpackages"""
module = importlib.import_module(package)
results = {}
for _, name, is_pkg in pkgutil.walk_packages((dirname(module.__file__),)):
full_name = module.__name__ + '.' + name
for _, name, is_pkg in pkgutil.walk_packages((package,)):
full_name = package + '.' + name
results[full_name] = importlib.import_module(full_name)
if is_pkg:
results.update(import_submodules(full_name))
Expand Down

0 comments on commit 9356ef8

Please sign in to comment.