Skip to content

Commit

Permalink
refactor: Add duties module to sys after loading it
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jun 27, 2023
1 parent a1d2629 commit 5730f5f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/duty/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import inspect
import sys
from copy import deepcopy
from importlib import util as importlib_util
from typing import Any, Callable, List, Union
Expand Down Expand Up @@ -195,6 +196,7 @@ def load(self, path: str | None = None) -> None:
spec = importlib_util.spec_from_file_location("duty.duties", path)
if spec:
duties = importlib_util.module_from_spec(spec)
sys.modules["duty.duties"] = duties
spec.loader.exec_module(duties) # type: ignore[union-attr]
declared_duties = inspect.getmembers(duties, lambda member: isinstance(member, Duty))
for _, duty in declared_duties:
Expand Down

0 comments on commit 5730f5f

Please sign in to comment.