mirror of https://github.com/Textualize/rich.git
Add max_depth arg to install()
This commit is contained in:
parent
0f693f5c3d
commit
13506c2367
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Parse ANSI escape sequences in pretty repr https://github.com/Textualize/rich/pull/2470
|
||||
- Add support for `FORCE_COLOR` env var https://github.com/Textualize/rich/pull/2449
|
||||
- Allow a `max_depth` argument to be passed to the `install()` hook https://github.com/Textualize/rich/issues/2486
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ The following people have contributed to the development of Rich:
|
|||
- [Will McGugan](https://github.com/willmcgugan)
|
||||
- [Paul McGuire](https://github.com/ptmcg)
|
||||
- [Antony Milne](https://github.com/AntonyMilneQB)
|
||||
- [Michael Milton](https://github.com/multimeric)
|
||||
- [Nathan Page](https://github.com/nathanrpage97)
|
||||
- [Avi Perl](https://github.com/avi-perl)
|
||||
- [Laurent Peuch](https://github.com/psycojoker)
|
||||
|
|
|
@ -120,6 +120,7 @@ def _ipy_display_hook(
|
|||
indent_guides: bool = False,
|
||||
max_length: Optional[int] = None,
|
||||
max_string: Optional[int] = None,
|
||||
max_depth: Optional[int] = None,
|
||||
expand_all: bool = False,
|
||||
) -> None:
|
||||
# needed here to prevent circular import:
|
||||
|
@ -177,6 +178,7 @@ def _ipy_display_hook(
|
|||
indent_guides=indent_guides,
|
||||
max_length=max_length,
|
||||
max_string=max_string,
|
||||
max_depth=max_depth,
|
||||
expand_all=expand_all,
|
||||
margin=12,
|
||||
),
|
||||
|
@ -202,6 +204,7 @@ def install(
|
|||
indent_guides: bool = False,
|
||||
max_length: Optional[int] = None,
|
||||
max_string: Optional[int] = None,
|
||||
max_depth: Optional[int] = None,
|
||||
expand_all: bool = False,
|
||||
) -> None:
|
||||
"""Install automatic pretty printing in the Python REPL.
|
||||
|
@ -214,6 +217,7 @@ def install(
|
|||
max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
|
||||
Defaults to None.
|
||||
max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
|
||||
max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None.
|
||||
expand_all (bool, optional): Expand all containers. Defaults to False.
|
||||
max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
|
||||
"""
|
||||
|
@ -236,6 +240,7 @@ def install(
|
|||
indent_guides=indent_guides,
|
||||
max_length=max_length,
|
||||
max_string=max_string,
|
||||
max_depth=max_depth,
|
||||
expand_all=expand_all,
|
||||
),
|
||||
crop=crop,
|
||||
|
@ -258,6 +263,7 @@ def install(
|
|||
indent_guides=indent_guides,
|
||||
max_length=max_length,
|
||||
max_string=max_string,
|
||||
max_depth=max_depth,
|
||||
expand_all=expand_all,
|
||||
)
|
||||
else:
|
||||
|
|
|
@ -51,6 +51,15 @@ def test_install():
|
|||
assert sys.displayhook is not dh
|
||||
|
||||
|
||||
def test_install_max_depth():
|
||||
console = Console(file=io.StringIO())
|
||||
dh = sys.displayhook
|
||||
install(console, max_depth=1)
|
||||
sys.displayhook({"foo": {"bar": True}})
|
||||
assert console.file.getvalue() == "{'foo': ...}\n"
|
||||
assert sys.displayhook is not dh
|
||||
|
||||
|
||||
def test_ipy_display_hook__repr_html():
|
||||
console = Console(file=io.StringIO(), force_jupyter=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue