Skip to content

Commit cd0972e

Browse files
committed
refactor get_ipython
1 parent a615bbe commit cd0972e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

dash/_jupyter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from IPython.core.ultratb import FormattedTB
2424
from retrying import retry
2525
from ansi2html import Ansi2HTMLConverter
26-
import IPython
2726
from ipykernel.comm import Comm
2827
import nest_asyncio
2928

@@ -34,7 +33,7 @@
3433
except ImportError:
3534
_dep_installed = False
3635
_dash_comm = None
37-
get_ipython = None
36+
get_ipython = lambda: None
3837

3938
JupyterDisplayMode = Literal["inline", "external", "jupyterlab", "tab"]
4039

@@ -93,7 +92,7 @@ def convert(name, locals=locals, formatarg=formatarg, formatvalue=formatvalue):
9392
def _send_jupyter_config_comm_request():
9493
# If running in an ipython kernel,
9594
# 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:
9796
if _dash_comm.kernel is not None:
9897
_caller["parent"] = _dash_comm.kernel.get_parent()
9998
_dash_comm.send({"type": "base_url_request"})
@@ -112,7 +111,7 @@ def _request_jupyter_config(timeout=2):
112111
_send_jupyter_config_comm_request()
113112

114113
# Get shell and kernel
115-
shell = IPython.get_ipython()
114+
shell = get_ipython()
116115
kernel = shell.kernel
117116

118117
# Start capturing shell events to replay later
@@ -203,7 +202,7 @@ def infer_jupyter_proxy_config(self):
203202
_request_jupyter_config()
204203

205204
def __init__(self):
206-
self.in_ipython = get_ipython and get_ipython() is not None
205+
self.in_ipython = get_ipython() is not None
207206
self.in_colab = "google.colab" in sys.modules
208207

209208
if _dep_installed and self.in_ipython and _dash_comm:

0 commit comments

Comments
 (0)