diff --git a/typer/main.py b/typer/main.py index 9db26975ca..6e2e890af9 100644 --- a/typer/main.py +++ b/typer/main.py @@ -38,10 +38,11 @@ try: import rich - from rich.console import Console from rich.traceback import Traceback - console_stderr = Console(stderr=True) + from . import rich_utils + + console_stderr = rich_utils._get_rich_console(stderr=True) except ImportError: # pragma: no cover rich = None # type: ignore @@ -69,12 +70,15 @@ def except_hook( supress_internal_dir_names = [typer_path, click_path] exc = exc_value if rich: + from .rich_utils import MAX_WIDTH + rich_tb = Traceback.from_exception( type(exc), exc, exc.__traceback__, show_locals=exception_config.pretty_exceptions_show_locals, suppress=supress_internal_dir_names, + width=MAX_WIDTH, ) console_stderr.print(rich_tb) return