diff --git a/news/10791.feature.rst b/news/10791.feature.rst new file mode 100644 index 00000000000..be41c6b7e21 --- /dev/null +++ b/news/10791.feature.rst @@ -0,0 +1 @@ +Print the exception via ``rich.traceback``, when running with ``--debug``. diff --git a/src/pip/_internal/cli/base_command.py b/src/pip/_internal/cli/base_command.py index f5dc0fecf78..78b96bb7070 100644 --- a/src/pip/_internal/cli/base_command.py +++ b/src/pip/_internal/cli/base_command.py @@ -10,6 +10,8 @@ from optparse import Values from typing import Any, Callable, List, Optional, Tuple +from pip._vendor.rich import traceback as rich_traceback + from pip._internal.cli import cmdoptions from pip._internal.cli.command_context import CommandContextMixIn from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter @@ -215,6 +217,7 @@ def exc_logging_wrapper(*args: Any) -> int: run = intercepts_unhandled_exc(self.run) else: run = self.run + rich_traceback.install(show_locals=True) return run(options, args) finally: self.handle_pip_version_check(options)