diff --git a/rich/pretty.py b/rich/pretty.py index 5c725c0c5..105c57e1f 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