Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Unify the width of the Rich console for help and errors #788

Merged
merged 3 commits into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading