File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed
packages/python/plotly/_plotly_utils Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change 22Stand-alone module to provide information about whether optional deps exist.
33
44"""
5+
56from importlib import import_module
67import logging
78import sys
@@ -19,16 +20,18 @@ def get_module(name, should_load=True):
1920 :return: (module|None) If import succeeds, the module will be returned.
2021
2122 """
22- if name in sys .modules :
23- return sys .modules [name ]
2423 if not should_load :
25- return None
26- if name not in _not_importable :
27- try :
28- return import_module (name )
29- except ImportError :
30- _not_importable .add (name )
31- except Exception :
32- _not_importable .add (name )
33- msg = f"Error importing optional module { name } "
34- logger .exception (msg )
24+ return sys .modules .get (name , None )
25+
26+ else :
27+ if name not in _not_importable :
28+ try :
29+ return import_module (name )
30+ except ImportError :
31+ _not_importable .add (name )
32+ except Exception :
33+ _not_importable .add (name )
34+ msg = f"Error importing optional module { name } "
35+ logger .exception (msg )
36+ else :
37+ return None
You can’t perform that action at this time.
0 commit comments