Skip to content

rich_check

Helper classes for rich pretty printing checks.

Check

Bases: BaseModel

Holds a success status and a message for an error check.

Source code in dapla_team_cli/pr/rich_check.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Check(BaseModel):
    """Holds a success status and a message for an error check."""

    status: Status
    message: str

    def get_status(self) -> Status:
        """Return the current status."""
        return self.status

    def __rich__(self) -> Padding:
        """Help Rich print with correct font colors and emojis."""
        if self.status is Status.Success:
            result = "✅[green]"
        elif self.status is Status.Failure:
            result = "❌[red] ERROR: "
        elif self.status is Status.Warning:
            result = "⚠️[yellow]  WARNING: "

        return Padding.indent(f"{result} {self.message}", 4)

__rich__()

Help Rich print with correct font colors and emojis.

Source code in dapla_team_cli/pr/rich_check.py
27
28
29
30
31
32
33
34
35
36
def __rich__(self) -> Padding:
    """Help Rich print with correct font colors and emojis."""
    if self.status is Status.Success:
        result = "✅[green]"
    elif self.status is Status.Failure:
        result = "❌[red] ERROR: "
    elif self.status is Status.Warning:
        result = "⚠️[yellow]  WARNING: "

    return Padding.indent(f"{result} {self.message}", 4)

get_status()

Return the current status.

Source code in dapla_team_cli/pr/rich_check.py
23
24
25
def get_status(self) -> Status:
    """Return the current status."""
    return self.status

RichFailure

Bases: Check

A failed check.

Source code in dapla_team_cli/pr/rich_check.py
45
46
47
48
class RichFailure(Check):
    """A failed check."""

    status: Status = Status.Failure

RichSuccess

Bases: Check

A successful check.

Source code in dapla_team_cli/pr/rich_check.py
39
40
41
42
class RichSuccess(Check):
    """A successful check."""

    status: Status = Status.Success

RichWarning

Bases: Check

A warning check.

Source code in dapla_team_cli/pr/rich_check.py
51
52
53
54
class RichWarning(Check):
    """A warning check."""

    status: Status = Status.Warning

Status

Bases: Enum

Enum for pretty checks.

Source code in dapla_team_cli/pr/rich_check.py
 9
10
11
12
13
14
class Status(Enum):
    """Enum for pretty checks."""

    Success = 1
    Failure = 2
    Warning = 3