Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Being more explicit with the import of importlib.util. #181

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Importing importlib.util in the one other place it is used.
  • Loading branch information
drewoldag committed Jan 23, 2025
commit 17cb213c85485925c652ef2412d626cb8fd62a15
7 changes: 4 additions & 3 deletions src/fibad/plugin_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib
from importlib import util as importlib_util
from typing import Any, Optional, TypeVar, Union

T = TypeVar("T")
@@ -71,10 +72,10 @@ def import_module_from_string(module_path: str) -> Any:
try:
# Attempt to find the module spec, i.e. `module.submodule.`.
# Will raise exception if `submodule`, 'subsubmodule', etc. is not found.
importlib.util.find_spec(module_name)
importlib_util.find_spec(module_name)

# `importlib.util.find_spec()` will return None if `module` is not found.
if (importlib.util.find_spec(module_name)) is not None:
# `importlib_util.find_spec()` will return None if `module` is not found.
if (importlib_util.find_spec(module_name)) is not None:
# Load the requested module
module = importlib.import_module(module_name)

Loading