MCPcopy
hub / github.com/Textualize/rich / _is_jupyter

Function _is_jupyter

rich/console.py:505–522  ·  view source on GitHub ↗

Check if we're running in a Jupyter notebook.

()

Source from the content-addressed store, hash-verified

503
504
505def _is_jupyter() -> bool: # pragma: no cover
506 """Check if we're running in a Jupyter notebook."""
507 try:
508 get_ipython # type: ignore[name-defined]
509 except NameError:
510 return False
511 ipython = get_ipython() # type: ignore[name-defined]
512 shell = ipython.__class__.__name__
513 if (
514 "google.colab" in str(ipython.__class__)
515 or os.getenv("DATABRICKS_RUNTIME_VERSION")
516 or shell == "ZMQInteractiveShell"
517 ):
518 return True # Jupyter notebook or qtconsole
519 elif shell == "TerminalInteractiveShell":
520 return False # Terminal running IPython
521 else:
522 return False # Other type (?)
523
524
525COLOR_SYSTEMS = {

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected