Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich.scope Namespace Reference

Functions

"ConsoleRenderable" render_scope ("Mapping[str, Any]" scope, *Optional[TextType] title=None, bool sort_keys=True, bool indent_guides=False, Optional[int] max_length=None, Optional[int] max_string=None)
 
None test (float foo, float bar)
 

Function Documentation

◆ render_scope()

"ConsoleRenderable" render_scope ( "Mapping[str, Any]"  scope,
*Optional[TextType]   title = None,
bool   sort_keys = True,
bool   indent_guides = False,
Optional[int]   max_length = None,
Optional[int]   max_string = None 
)
Render python variables in a given scope.

Args:
    scope (Mapping): A mapping containing variable names and values.
    title (str, optional): Optional title. Defaults to None.
    sort_keys (bool, optional): Enable sorting of items. Defaults to True.
    indent_guides (bool, optional): Enable indentation guides. Defaults to False.
    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.

Returns:
    ConsoleRenderable: A renderable object.

Definition at line 14 of file scope.py.

22) -> "ConsoleRenderable":
23 """Render python variables in a given scope.
24
25 Args:
26 scope (Mapping): A mapping containing variable names and values.
27 title (str, optional): Optional title. Defaults to None.
28 sort_keys (bool, optional): Enable sorting of items. Defaults to True.
29 indent_guides (bool, optional): Enable indentation guides. Defaults to False.
30 max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
31 Defaults to None.
32 max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
33
34 Returns:
35 ConsoleRenderable: A renderable object.
36 """
37 highlighter = ReprHighlighter()
38 items_table = Table.grid(padding=(0, 1), expand=False)
39 items_table.add_column(justify="right")
40
41 def sort_items(item: Tuple[str, Any]) -> Tuple[bool, str]:
42 """Sort special variables first, then alphabetically."""
43 key, _ = item
44 return (not key.startswith("__"), key.lower())
45
46 items = sorted(scope.items(), key=sort_items) if sort_keys else scope.items()
47 for key, value in items:
48 key_text = Text.assemble(
49 (key, "scope.key.special" if key.startswith("__") else "scope.key"),
50 (" =", "scope.equals"),
51 )
53 key_text,
54 Pretty(
55 value,
56 highlighter=highlighter,
57 indent_guides=indent_guides,
58 max_length=max_length,
59 max_string=max_string,
60 ),
61 )
62 return Panel.fit(
63 items_table,
64 title=title,
65 border_style="scope.border",
66 padding=(0, 1),
67 )
68
69
for i

References i.

◆ test()

None test ( float  foo,
float  bar 
)

Definition at line 75 of file scope.py.

75 def test(foo: float, bar: float) -> None:
76 list_of_things = [1, 2, 3, None, 4, True, False, "Hello World"]
77 dict_of_things = {
78 "version": "1.1",
79 "method": "confirmFruitPurchase",
80 "params": [["apple", "orange", "mangoes", "pomelo"], 1.123],
81 "id": "194521489",
82 }
83 print(render_scope(locals(), title="[i]locals", sort_keys=False))
84

References pip._vendor.rich.scope.test().

Referenced by pip._vendor.rich.scope.test().

Here is the call graph for this function:
Here is the caller graph for this function: