Skip to content

Commit

Permalink
fix: throw import exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Aug 24, 2024
1 parent 0d8b3d1 commit f1dd479
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dewret/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def load_module_or_package(target_name: str, path: Path) -> ModuleType:
spec = importlib.util.spec_from_file_location(target_name, str(package_init))
if spec is None or spec.loader is None:
raise ImportError(f"Could not open {path.parent} package")
module = importlib.util.module_from_spec(spec)
sys.modules[target_name] = module
spec.loader.exec_module(module)
package = importlib.util.module_from_spec(spec)
sys.modules[target_name] = package
spec.loader.exec_module(package)
module = importlib.import_module(f"{target_name}.{path.stem}", target_name)
except ImportError as exc:
exception = exc
Expand Down

0 comments on commit f1dd479

Please sign in to comment.