MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / rich_print_str

Function rich_print_str

tests/lib/utils.py:66–86  ·  view source on GitHub ↗

Like `rich.print()` but returns the string instead

(obj: object)

Source from the content-addressed store, hash-verified

64
65
66def rich_print_str(obj: object) -> str:
67 """Like `rich.print()` but returns the string instead"""
68
69 buf = io.StringIO()
70 console = rich.console.Console(
71 file=buf,
72 width=120,
73 force_terminal=False,
74 color_system=None,
75 record=True,
76 )
77
78 # Use Rich's pretty printer for nice multi-line formatting
79 rich.pretty.install(console)
80 console.print(obj, overflow="fold", width=120)
81
82 result = buf.getvalue()
83 # Strip out [~...] patterns to exclude generic content from snapshots
84 result = re.sub(r"\[~[^\]]*\]", "", result)
85 result = result.replace("[TypeVar]", "")
86 return result

Callers 1

print_objFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected