Skip to content

Commit

Permalink
fix #674: be more careful when importing plug-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer committed Oct 31, 2024
1 parent 22b7c79 commit 8573623
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/harlequin/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ def _load_plugins(
group: str,
) -> dict[str, HarlequinKeyMap] | dict[str, type[HarlequinAdapter]]:
eps = entry_points(group=group)
try:
plugins: dict[str, HarlequinKeyMap] | dict[str, type[HarlequinAdapter]] = {
ep.name: ep.load() for ep in eps
}
except ImportError as e:
print(
f"Harlequin could not load the installed plug-in named {e.name}." f"\n\n{e}"
)
plugins: dict[str, HarlequinKeyMap] | dict[str, type[HarlequinAdapter]] = {}
for ep in eps:
try:
ep_class = ep.load()
except ImportError as e:
print(
f"Harlequin could not load the installed plug-in named {e.name}."
f"\n\n{e}"
)
else:
plugins[ep.name] = ep_class
return plugins

0 comments on commit 8573623

Please sign in to comment.