From 18465d36eedcff93c37e3f165cd818b355152a2e Mon Sep 17 00:00:00 2001 From: liblaf <30631553+liblaf@users.noreply.github.com> Date: Thu, 19 Jun 2025 17:51:31 +0800 Subject: [PATCH] Add truncation for long object representations in traverse function --- rich/pretty.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rich/pretty.py b/rich/pretty.py index 5c725c0c53..105c57e1ff 100644 --- a/rich/pretty.py +++ b/rich/pretty.py @@ -610,6 +610,8 @@ def to_repr(obj: Any) -> str: else: try: obj_repr = repr(obj) + if max_string is not None and len(obj_repr) > max_string: + obj_repr = f"{obj_repr[:max_string]}..." except Exception as error: obj_repr = f"" return obj_repr