23
23
from IPython .core .ultratb import FormattedTB
24
24
from retrying import retry
25
25
from ansi2html import Ansi2HTMLConverter
26
- import IPython
27
26
from ipykernel .comm import Comm
28
27
import nest_asyncio
29
28
34
33
except ImportError :
35
34
_dep_installed = False
36
35
_dash_comm = None
37
- get_ipython = None
36
+ get_ipython = lambda : None
38
37
39
38
JupyterDisplayMode = Literal ["inline" , "external" , "jupyterlab" , "tab" ]
40
39
@@ -93,7 +92,7 @@ def convert(name, locals=locals, formatarg=formatarg, formatvalue=formatvalue):
93
92
def _send_jupyter_config_comm_request ():
94
93
# If running in an ipython kernel,
95
94
# request that the front end extension send us the notebook server base URL
96
- if IPython . get_ipython () is not None :
95
+ if get_ipython () is not None :
97
96
if _dash_comm .kernel is not None :
98
97
_caller ["parent" ] = _dash_comm .kernel .get_parent ()
99
98
_dash_comm .send ({"type" : "base_url_request" })
@@ -112,7 +111,7 @@ def _request_jupyter_config(timeout=2):
112
111
_send_jupyter_config_comm_request ()
113
112
114
113
# Get shell and kernel
115
- shell = IPython . get_ipython ()
114
+ shell = get_ipython ()
116
115
kernel = shell .kernel
117
116
118
117
# Start capturing shell events to replay later
@@ -203,7 +202,7 @@ def infer_jupyter_proxy_config(self):
203
202
_request_jupyter_config ()
204
203
205
204
def __init__ (self ):
206
- self .in_ipython = get_ipython and get_ipython () is not None
205
+ self .in_ipython = get_ipython () is not None
207
206
self .in_colab = "google.colab" in sys .modules
208
207
209
208
if _dep_installed and self .in_ipython and _dash_comm :
0 commit comments