From 01d1563d0c9f6817a5a7a8b2c87e16f8ef0682c8 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 6 Mar 2021 14:46:50 +0000 Subject: [PATCH] add test for google colab --- rich/console.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rich/console.py b/rich/console.py index 9b00b6a3..46caf664 100644 --- a/rich/console.py +++ b/rich/console.py @@ -408,8 +408,9 @@ def _is_jupyter() -> bool: # pragma: no cover get_ipython # type: ignore except NameError: return False - shell = get_ipython().__class__.__name__ # type: ignore - if shell == "ZMQInteractiveShell": + ipython = get_ipython() + shell = ipython.__class__.__name__ # type: ignore + if "google.colab" in str(ipython.__class__) or shell == "ZMQInteractiveShell": return True # Jupyter notebook or qtconsole elif shell == "TerminalInteractiveShell": return False # Terminal running IPython