Replacement sys.displayhook which prettifies objects with Rich.
(value: Any)
| 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] |
nothing calls this directly
no test coverage detected