Skip to content

Commit

Permalink
Fix AttributeError and load modules into sys.modules
Browse files Browse the repository at this point in the history
  • Loading branch information
pvk-developer committed Oct 15, 2024
1 parent abaca7a commit 1aa7240
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions copulas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ def _find_addons():
for entry_point in eps:
try:
addon = entry_point.load()
except Exception: # pylint: disable=broad-exception-caught
msg = f'Failed to load "{entry_point.name}" from "{entry_point.value}".'
except Exception as e: # pylint: disable=broad-exception-caught
msg = (
f'Failed to load "{entry_point.name}" from "{entry_point.value}" '
f'with error:\n{e}'
)
warnings.warn(msg)
continue

Expand All @@ -331,6 +334,11 @@ def _find_addons():
warnings.warn(msg)
continue

if isinstance(addon, ModuleType):
addon_module_name = f'{addon_target.__name__}.{addon_name}'
if addon_module_name not in sys.modules:
sys.modules[addon_module_name] = addon

setattr(addon_target, addon_name, addon)


Expand Down

0 comments on commit 1aa7240

Please sign in to comment.