Skip to content

Commit

Permalink
fix(utils): add is_importable method to PKGs class
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Jul 24, 2023
1 parent 4ad0302 commit 65fbc33
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/hyfi/utils/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,8 @@ def get_caller_module_name(caller_stack_depth: int = 2) -> str:
f"Error getting caller module name at depth {caller_stack_depth}: {e}"
)
return ""

@staticmethod
def is_importable(module_name: str) -> bool:
module_spec = importlib.util.find_spec(module_name) # type: ignore
return module_spec is not None

0 comments on commit 65fbc33

Please sign in to comment.