fix(s52): resolve ConsoleNotifier default stream at call time
This commit is contained in:
parent
cd8553c7ee
commit
7ec60618b0
2 changed files with 24 additions and 4 deletions
|
|
@ -47,13 +47,18 @@ class NotifyRefused(Exception):
|
|||
|
||||
|
||||
class ConsoleNotifier:
|
||||
"""One-line verdict summary to a text stream (default stdout). Never receives a URL."""
|
||||
"""One-line verdict summary to a text stream (default stdout). Never receives a URL.
|
||||
|
||||
def __init__(self, stream: TextIO = sys.stdout) -> None:
|
||||
The default stream is resolved at CALL time (``None`` → current ``sys.stdout``), so a later
|
||||
``redirect_stdout``/capture is honored — an import-time ``sys.stdout`` default would bind the
|
||||
original stream object and bypass the redirect."""
|
||||
|
||||
def __init__(self, stream: TextIO | None = None) -> None:
|
||||
self._stream = stream
|
||||
|
||||
def __call__(self, verdict: Verdict) -> None:
|
||||
print(f"[notify] verdict {verdict.id} decision={verdict.decision}", file=self._stream)
|
||||
stream = self._stream if self._stream is not None else sys.stdout
|
||||
print(f"[notify] verdict {verdict.id} decision={verdict.decision}", file=stream)
|
||||
|
||||
|
||||
def _verdict_payload(verdict: Verdict) -> dict[str, Any]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue