MCPcopy
hub / github.com/Textualize/rich / display_hook

Function display_hook

rich/pretty.py:200–221  ·  view source on GitHub ↗

Replacement sys.displayhook which prettifies objects with Rich.

(value: Any)

Source from the content-addressed store, hash-verified

198 assert console is not None
199
200 def display_hook(value: Any) -> None:
201 """Replacement sys.displayhook which prettifies objects with Rich."""
202 if value is not None:
203 assert console is not None
204 builtins._ = None # type: ignore[attr-defined]
205 console.print(
206 (
207 value
208 if _safe_isinstance(value, RichRenderable)
209 else Pretty(
210 value,
211 overflow=overflow,
212 indent_guides=indent_guides,
213 max_length=max_length,
214 max_string=max_string,
215 max_depth=max_depth,
216 expand_all=expand_all,
217 )
218 ),
219 crop=crop,
220 )
221 builtins._ = value # type: ignore[attr-defined]
222
223 try:
224 ip = get_ipython() # type: ignore[name-defined]

Callers

nothing calls this directly

Calls 3

_safe_isinstanceFunction · 0.85
PrettyClass · 0.85
printMethod · 0.80

Tested by

no test coverage detected