Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
8 changes: 5 additions & 3 deletions packages/python/plotly/_plotly_utils/optional_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Stand-alone module to provide information about whether optional deps exist.

"""

from importlib import import_module
import logging
import sys
Expand All @@ -19,10 +20,9 @@ def get_module(name, should_load=True):
:return: (module|None) If import succeeds, the module will be returned.

"""
if name in sys.modules:
return sys.modules[name]
if not should_load:
return None
return sys.modules.get(name, None)

if name not in _not_importable:
try:
return import_module(name)
Expand All @@ -32,3 +32,5 @@ def get_module(name, should_load=True):
_not_importable.add(name)
msg = f"Error importing optional module {name}"
logger.exception(msg)

return None
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.25.1
tenacity==6.2.0
pytest==6.2.3
pytest==8.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ numpy==1.20.2
xarray==0.17.0
statsmodels
Pillow==8.2.0
pytest==6.2.3
pytest==8.1.1
pytz==2021.1
ipython[all]==7.22.0
ipywidgets==8.0.2
Expand Down