• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 26342152999

23 May 2026 07:59PM UTC coverage: 91.165% (-1.6%) from 92.792%
26342152999

push

github

web-flow
Run Linux ARM CI on Depot runners (#23363)

RunsOn is deprecating their v2 stack, and rather than migrate
to v3 we should use the resources kindly donated by Depot.

GitHub also now has Linux ARM runners, should we need them.

87305 of 95766 relevant lines covered (91.16%)

3.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.15
/src/python/pants/engine/console.py
1
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
from __future__ import annotations
11✔
4

5
import sys
11✔
6
from collections.abc import Callable
11✔
7
from typing import TextIO
11✔
8

9
from colors import blue, cyan, green, magenta, red, yellow
11✔
10

11
from pants.engine.engine_aware import SideEffecting
11✔
12
from pants.engine.internals.scheduler import SchedulerSession
11✔
13

14

15
class Console(SideEffecting):
11✔
16
    """Class responsible for writing text to the console while Pants is running.
17

18
    A SchedulerSession should always be set in production usage, in order to track side effects, and
19
    tear down any running UI before stdio is rendered.
20
    """
21

22
    def __init__(
11✔
23
        self,
24
        stdin: TextIO | None = None,
25
        stdout: TextIO | None = None,
26
        stderr: TextIO | None = None,
27
        use_colors: bool = True,
28
        session: SchedulerSession | None = None,
29
    ):
30
        self._stdin = stdin or sys.stdin
11✔
31
        self._stdout = stdout or sys.stdout
11✔
32
        self._stderr = stderr or sys.stderr
11✔
33
        self._use_colors = use_colors
11✔
34
        self._session = session
11✔
35
        self._enforce_effects = self._session is not None
11✔
36

37
    @property
11✔
38
    def stdin(self) -> TextIO:
11✔
39
        if self._session:
1✔
40
            self.side_effected()
×
41
            self._session.teardown_dynamic_ui()
×
42
        return self._stdin
1✔
43

44
    @property
11✔
45
    def stdout(self) -> TextIO:
11✔
46
        if self._session:
11✔
47
            self.side_effected()
10✔
48
            self._session.teardown_dynamic_ui()
10✔
49
        return self._stdout
11✔
50

51
    @property
11✔
52
    def stderr(self) -> TextIO:
11✔
53
        if self._session:
5✔
54
            self.side_effected()
4✔
55
            self._session.teardown_dynamic_ui()
4✔
56
        return self._stderr
5✔
57

58
    def input(self, prompt: str | None = None) -> str:
11✔
59
        """Equivalent to the `input` builtin, but clears any running UI before rendering."""
60
        if prompt is not None:
1✔
61
            self.write_stdout(prompt)
1✔
62
        return self.stdin.readline().rstrip("\n")
1✔
63

64
    def write_stdout(self, payload: str) -> None:
11✔
65
        self.stdout.write(payload)
8✔
66

67
    def write_stderr(self, payload: str) -> None:
11✔
68
        self.stderr.write(payload)
5✔
69

70
    def print_stdout(self, payload: str, end: str = "\n") -> None:
11✔
71
        self.write_stdout(f"{payload}{end}")
7✔
72

73
    def print_stderr(self, payload: str, end: str = "\n") -> None:
11✔
74
        self.write_stderr(f"{payload}{end}")
5✔
75

76
    def flush(self) -> None:
11✔
77
        self._stdout.flush()
11✔
78
        self._stderr.flush()
11✔
79

80
    def sigil_succeeded(self) -> str:
11✔
81
        """Sigil for a successful item."""
82
        return self.green("✓")
4✔
83

84
    def sigil_succeeded_with_edits(self) -> str:
11✔
85
        """Sigil for a successful item which caused an edit to the workspace."""
86
        return self.yellow("+")
2✔
87

88
    def sigil_failed(self) -> str:
11✔
89
        """Sigil for a failed item."""
90
        return self.red("✕")
2✔
91

92
    def sigil_skipped(self) -> str:
11✔
93
        """Sigil for a skipped item."""
94
        return self.yellow("-")
1✔
95

96
    @property
11✔
97
    def use_colors(self):
11✔
98
        return self._use_colors
×
99

100
    def _safe_color(self, text: str, color: Callable[[str], str]) -> str:
11✔
101
        """We should only output color when the global flag --colors is enabled."""
102
        return color(text) if self._use_colors else text
5✔
103

104
    def blue(self, text: str) -> str:
11✔
105
        return self._safe_color(text, blue)
1✔
106

107
    def cyan(self, text: str) -> str:
11✔
108
        return self._safe_color(text, cyan)
×
109

110
    def green(self, text: str) -> str:
11✔
111
        return self._safe_color(text, green)
4✔
112

113
    def magenta(self, text: str) -> str:
11✔
114
        return self._safe_color(text, magenta)
×
115

116
    def red(self, text: str) -> str:
11✔
117
        return self._safe_color(text, red)
2✔
118

119
    def yellow(self, text: str) -> str:
11✔
120
        return self._safe_color(text, yellow)
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc