Skip to content

Console

Handling the CLIs output to users.

Bases: Console

A high level console interface.

This is not a true sub-class of rich.Console, it merely proxies most calls to an underlying rich.Console instance, but that's hard to correctly type with mypy, so lie. Maybe life will be better one day[1].

[1] https://github.com/python/typing/issues/802

Source code in nava/platform/cli/console.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class ConsoleWrapper(Console):
    """A high level console interface.

    This is not a true sub-class of `rich.Console`, it merely proxies most calls
    to an underlying `rich.Console` instance, but that's hard to correctly type
    with mypy, so lie. Maybe life will be better one day[1].

    [1] https://github.com/python/typing/issues/802
    """

    output_level: config.OutputLevel
    default: Console
    warning: Console
    error: Console

    def __init__(
        self, output_level: config.OutputLevel, default: Console, warning: Console, error: Console
    ) -> None:
        self.output_level = output_level
        self.default = default
        self.warning = warning
        self.error = error

    def __getattr__(self, attr: str) -> Any:
        return getattr(self.default, attr)