Skip to content

Debugging

tap(item: T, label: Optional[str] = None) -> T

Prints the given item with an optional label and returns it.

Parameters:

Name Type Description Default
item T

The item to print.

required
label Optional[str]

The label to use.

None

Returns:

Type Description
T

The given item.

Source code in src/funcs/debugging.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def tap(item: T, label: Optional[str] = None) -> T:
    """Prints the given item with an optional label and returns it.

    Arguments:
        item: The item to print.
        label: The label to use.

    Returns:
        The given item.
    """
    if label is None:
        print(item)

    else:
        print(label_string(label, item))

    return item

inspect(function: Inspect[T], item: T) -> T

Inspects the given item with the function and returns it.

Parameters:

Name Type Description Default
function Inspect[T]

The function to use.

required
item T

The item to inspect.

required

Returns:

Type Description
T

The given item.

Source code in src/funcs/debugging.py
34
35
36
37
38
39
40
41
42
43
44
45
46
def inspect(function: Inspect[T], item: T) -> T:
    """Inspects the given item with the `function` and returns it.

    Arguments:
        function: The function to use.
        item: The item to inspect.

    Returns:
        The given item.
    """
    function(item)

    return item