diff --git a/devtools/debug.py b/devtools/debug.py index 89cda24..036b04a 100644 --- a/devtools/debug.py +++ b/devtools/debug.py @@ -134,9 +134,14 @@ def format(self, *args: 'Any', frame_depth_: int = 2, **kwargs: 'Any') -> DebugO return self._process(args, kwargs, frame_depth_) def breakpoint(self) -> None: - import pdb - - pdb.Pdb(skip=['devtools.*']).set_trace() + """ + Launch IPython debugger if installed. Otherwise, launch pdb. + """ + try: + from IPython.terminal.debugger import TerminalPdb as Pdb # type: ignore + except ImportError: + from pdb import Pdb + Pdb(skip=['devtools.*']).set_trace() def timer(self, name: 'Optional[str]' = None, *, verbose: bool = True, file: 'Any' = None, dp: int = 3) -> Timer: return Timer(name=name, verbose=verbose, file=file, dp=dp)