Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -5,10 +5,11 @@ import dataclasses
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
import typing
|
||||
|
||||
from routing_figures.calls import Call, SENTENCES
|
||||
from failure import Failure
|
||||
from text_files.file_writes import replace_file, replace_json
|
||||
from text_files.file_writes import replace_json
|
||||
from text_files.utc_stamp import STAMPED
|
||||
|
||||
CYCLES_PER_CHECK = 20
|
||||
@@ -100,8 +101,8 @@ def raised(root: pathlib.Path) -> Raised | Failure:
|
||||
return Raised(since, frozenset(entry.call for entry in kept.raised if entry.at > since))
|
||||
|
||||
|
||||
def mark_raised(root: pathlib.Path, calls: list[Call], at: str) -> Failure | None:
|
||||
"""Keeps the calls in STATE, and adds a line for each to RAISED."""
|
||||
def mark_raised(root: pathlib.Path, calls: list[Call], at: str, replace: typing.Callable[[pathlib.Path, bytes], Failure | None]) -> Failure | None:
|
||||
"""Keeps the calls in STATE, and adds a line for each to RAISED, which replace writes as replace_file does."""
|
||||
kept = read_state(root)
|
||||
if isinstance(kept, Failure):
|
||||
return kept
|
||||
@@ -112,7 +113,7 @@ def mark_raised(root: pathlib.Path, calls: list[Call], at: str) -> Failure | Non
|
||||
return unwritten
|
||||
# The first line opens a list below the heading; each later one joins it.
|
||||
gap = "\n" if RAISED_LINE.search(text) else "\n\n"
|
||||
unwritten = replace_file(root / RAISED, (text.rstrip("\n") + gap + "".join(f"- {at} {call.sentence()}\n" for call in calls)).encode())
|
||||
unwritten = replace(root / RAISED, (text.rstrip("\n") + gap + "".join(f"- {at} {call.sentence()}\n" for call in calls)).encode())
|
||||
return Failure(f"could not write {root / RAISED}: {unwritten.reason}") if unwritten else None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user