Path 1: 2 calls (1.0)

dict (2)

'[i]locals' (1) 'locals' (1)

True (2)

False (1) True (1)

None (1) 10 (1)

None (1) 80 (1)

Panel (2)

1def render_scope(
2    scope: "Mapping[str, Any]",
3    *,
4    title: Optional[TextType] = None,
5    sort_keys: bool = True,
6    indent_guides: bool = False,
7    max_length: Optional[int] = None,
8    max_string: Optional[int] = None,
9) -> "ConsoleRenderable":
10    """Render python variables in a given scope.
11
12    Args:
13        scope (Mapping): A mapping containing variable names and values.
14        title (str, optional): Optional title. Defaults to None.
15        sort_keys (bool, optional): Enable sorting of items. Defaults to True.
16        indent_guides (bool, optional): Enable indentation guides. Defaults to False.
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. Defaults to None.
20
21    Returns:
22        ConsoleRenderable: A renderable object.
23    """
24    highlighter = ReprHighlighter()
25    items_table = Table.grid(padding=(0, 1), expand=False)
26    items_table.add_column(justify="right")
27
28    def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
29        """Sort special variables first, then alphabetically."""
30        key, _ = item
31        return (not key.startswith("__"), key.lower())
32
33    items = sorted(scope.items(), key=sort_items) if sort_keys else scope.items()
34    for key, value in items:
35        key_text = Text.assemble(
36            (key, "scope.key.special" if key.startswith("__") else "scope.key"),
37            (" =", "scope.equals"),
38        )
39        items_table.add_row(
40            key_text,
41            Pretty(
42                value,
43                highlighter=highlighter,
44                indent_guides=indent_guides,
45                max_length=max_length,
46                max_string=max_string,
47            ),
48        )
49    return Panel.fit(
50        items_table,
51        title=title,
52        border_style="scope.border",
53        padding=(0, 1),
54    )