Path 1: 161 calls (0.95)

1 (45) Layout (18) dict (16) 0 (14) Console (6) test_broken_call_attr..NotCallable (4) list (4) (1,) (4) ExampleDataclass (3) test_reference_c...

80 (59) 48 (16) 26 (9) 15 (8) 1 (8) 27 (8) 6 (6) 100 (5) 29 (4) 46 (4)

4 (161)

None (155) 10 (4) 2 (2)

None (156) 60 (4) 8 (1)

None (150) 2 (4) 1 (3) 0 (1) 3 (1) 4 (1) 5 (1)

False (155) True (6)

'1' (45) '0' (14) '' (6) "{\n 'foo': [3.1427, ('Paul Atreides', 'Vladimir Harkonnen', 'Thufir Hawat')],\n ...

1def pretty_repr(
2    _object: Any,
3    *,
4    max_width: int = 80,
5    indent_size: int = 4,
6    max_length: Optional[int] = None,
7    max_string: Optional[int] = None,
8    max_depth: Optional[int] = None,
9    expand_all: bool = False,
10) -> str:
11    """Prettify repr string by expanding on to new lines to fit within a given width.
12
13    Args:
14        _object (Any): Object to repr.
15        max_width (int, optional): Desired maximum width of repr string. Defaults to 80.
16        indent_size (int, optional): Number of spaces to indent. Defaults to 4.
17        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
18            Defaults to None.
19        max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
20            Defaults to None.
21        max_depth (int, optional): Maximum depth of nested data structure, or None for no depth.
22            Defaults to None.
23        expand_all (bool, optional): Expand all containers regardless of available width. Defaults to False.
24
25    Returns:
26        str: A possibly multi-line representation of the object.
27    """
28
29    if _safe_isinstance(_object, Node):
30        node = _object
31    else:
32        node = traverse(
33            _object, max_length=max_length, max_string=max_string, max_depth=max_depth
34        )
35    repr_str: str = node.render(
36        max_width=max_width, indent_size=indent_size, expand_all=expand_all
37    )
38    return repr_str
            

Path 2: 9 calls (0.05)

Node (9)

34 (4) 92 (3) 80 (1) 24 (1)

4 (9)

10 (8) None (1)

80 (8) None (1)

None (9)

False (9)

'' (8) 'abc: ' (1)

1def pretty_repr(
2    _object: Any,
3    *,
4    max_width: int = 80,
5    indent_size: int = 4,
6    max_length: Optional[int] = None,
7    max_string: Optional[int] = None,
8    max_depth: Optional[int] = None,
9    expand_all: bool = False,
10) -> str:
11    """Prettify repr string by expanding on to new lines to fit within a given width.
12
13    Args:
14        _object (Any): Object to repr.
15        max_width (int, optional): Desired maximum width of repr string. Defaults to 80.
16        indent_size (int, optional): Number of spaces to indent. Defaults to 4.
17        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
18            Defaults to None.
19        max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
20            Defaults to None.
21        max_depth (int, optional): Maximum depth of nested data structure, or None for no depth.
22            Defaults to None.
23        expand_all (bool, optional): Expand all containers regardless of available width. Defaults to False.
24
25    Returns:
26        str: A possibly multi-line representation of the object.
27    """
28
29    if _safe_isinstance(_object, Node):
30        node = _object
31    else:
32        node = traverse(
33            _object, max_length=max_length, max_string=max_string, max_depth=max_depth
34        )
35    repr_str: str = node.render(
36        max_width=max_width, indent_size=indent_size, expand_all=expand_all
37    )
38    return repr_str