def patch_ipdb(force: bool = False):
  """Patches the IPython debugger to use `IPython.display.display`."""
  global old_displayhook
  if old_displayhook is not None and not force:
    raise ValueError(
        "IPython.core.debugger.Pdb.displayhook has already been patched!"
    )
  old_displayhook = IPython.core.debugger.Pdb.displayhook
  IPython.core.debugger.Pdb.displayhook = displayhook_with_ipython
Patches the IPython debugger to use `IPython.display.display`.
penzai/toolshed/patch_ipdb.py