From 3a5f09743ac2bac56846fe4fec0ee8c224343915 Mon Sep 17 00:00:00 2001 From: Nok Chan Date: Wed, 27 Jul 2022 16:17:38 +0100 Subject: [PATCH] Detect Databricks notebook as Jupyter environment --- rich/console.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rich/console.py b/rich/console.py index 8c6049a4..3369a90b 100644 --- a/rich/console.py +++ b/rich/console.py @@ -516,7 +516,11 @@ def _is_jupyter() -> bool: # pragma: no cover return False ipython = get_ipython() # type: ignore[name-defined] shell = ipython.__class__.__name__ - if "google.colab" in str(ipython.__class__) or shell == "ZMQInteractiveShell": + if ( + "google.colab" in str(ipython.__class__) + or os.getenv("DATABRICKS_ROOT_VIRTUALENV_ENV") + or shell == "ZMQInteractiveShell" + ): return True # Jupyter notebook or qtconsole elif shell == "TerminalInteractiveShell": return False # Terminal running IPython