Skip to content

Commit 493dd8e

Browse files
racinmatpre-commit-ci[bot]svlandeg
authored
💄 Unify the width of the Rich console for help and errors (#788)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: svlandeg <[email protected]>
1 parent 8c0c003 commit 493dd8e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

typer/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939

4040
try:
4141
import rich
42-
from rich.console import Console
4342
from rich.traceback import Traceback
4443

45-
console_stderr = Console(stderr=True)
44+
from . import rich_utils
45+
46+
console_stderr = rich_utils._get_rich_console(stderr=True)
4647

4748
except ImportError: # pragma: no cover
4849
rich = None # type: ignore
@@ -70,12 +71,15 @@ def except_hook(
7071
supress_internal_dir_names = [typer_path, click_path]
7172
exc = exc_value
7273
if rich:
74+
from .rich_utils import MAX_WIDTH
75+
7376
rich_tb = Traceback.from_exception(
7477
type(exc),
7578
exc,
7679
exc.__traceback__,
7780
show_locals=exception_config.pretty_exceptions_show_locals,
7881
suppress=supress_internal_dir_names,
82+
width=MAX_WIDTH,
7983
)
8084
console_stderr.print(rich_tb)
8185
return

0 commit comments

Comments
 (0)