Method: rich.console._is_jupyter
Calls: 324, Exceptions: 324, Paths: 1Back
Path 1: 324 calls (1.0)
False (324)
NameError (324)
1def _is_jupyter() -> bool: # pragma: no cover
2 """Check if we're running in a Jupyter notebook."""
3 try:
4 get_ipython # type: ignore[name-defined]
5 except NameError:
6 return False
7 ipython = get_ipython() # type: ignore[name-defined]
8 shell = ipython.__class__.__name__
9 if (
10 "google.colab" in str(ipython.__class__)
11 or os.getenv("DATABRICKS_RUNTIME_VERSION")
12 or shell == "ZMQInteractiveShell"
13 ):
14 return True # Jupyter notebook or qtconsole
15 elif shell == "TerminalInteractiveShell":
16 return False # Terminal running IPython
17 else:
18 return False # Other type (?)