Skip to content

Commit 3be5cd1

Browse files
committed
style: fix pycodestyle E127/E128/E302/E306 in sin_delegate
1 parent 6dead01 commit 3be5cd1

9 files changed

Lines changed: 31 additions & 24 deletions

File tree

‎src/sin_delegate/budget_governor.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class BudgetGovernor:
4242
min_grant: float = 60.0
4343

4444
_pool: float = field(init=False, default=0.0)
45-
_allocs: dict[str, Allocation] = field(init=False,
46-
default_factory=dict)
45+
_allocs: dict[str, Allocation] = field(
46+
init=False, default_factory=dict)
4747
_deadline: float = field(init=False, default=0.0)
48-
_lock: asyncio.Lock = field(init=False,
49-
default_factory=asyncio.Lock)
48+
_lock: asyncio.Lock = field(
49+
init=False, default_factory=asyncio.Lock)
5050

5151
def __post_init__(self) -> None:
5252
self._deadline = time.monotonic() + self.global_seconds

‎src/sin_delegate/models.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ def finalize(self) -> "Task":
7878
"backend": self.agent.backend,
7979
}, sort_keys=True).encode()
8080
tid = hashlib.blake2b(payload, digest_size=8).hexdigest()
81-
return Task(**{**{f: getattr(self, f)
82-
for f in self.__dataclass_fields__},
83-
"id": tid})
81+
return Task(
82+
**{**{f: getattr(self, f)
83+
for f in self.__dataclass_fields__},
84+
"id": tid})
8485

8586

8687
@dataclass(frozen=True)

‎src/sin_delegate/multirepo.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ def multirepo_plan_from_dict(data: dict) -> MultiRepoPlan:
131131
# for these tasks, since title+instructions+backend are the
132132
# primary input and deps are resolved after finalization).
133133
if task.id != title_to_id[key]:
134-
task = Task(**{**{f: getattr(task, f)
135-
for f in task.__dataclass_fields__},
136-
"id": title_to_id[key]})
134+
task = Task(
135+
**{**{f: getattr(task, f)
136+
for f in task.__dataclass_fields__},
137+
"id": title_to_id[key]})
137138
tasks.append(task)
138139
key_repo[task.id] = rname
139140

‎src/sin_delegate/planfile.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ def plan_from_dict(data: dict, repo: str = ".") -> Plan:
4343
key = rt.get("key") or rt["title"]
4444
draft = _task_from(rt, deps=())
4545
if rt.get("id"):
46-
draft = Task(**{**{f: getattr(draft, f)
47-
for f in draft.__dataclass_fields__},
48-
"id": rt["id"]})
46+
draft = Task(
47+
**{**{f: getattr(draft, f)
48+
for f in draft.__dataclass_fields__},
49+
"id": rt["id"]})
4950
drafts[key] = draft
5051

5152
key_to_final_id = {k: t.id or t.finalize().id

‎src/sin_delegate/runner.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ async def run(self, task: Task, cwd: str,
7777
except asyncio.TimeoutError:
7878
proc.kill()
7979
await proc.wait()
80-
return RunnerResult(False,
81-
f"[timeout after {timeout:.0f}s]", -1)
80+
return RunnerResult(
81+
False, f"[timeout after {timeout:.0f}s]", -1)
8282
text = redact(out.decode(errors="replace"))[-100_000:]
83-
return RunnerResult(proc.returncode == 0, text,
84-
proc.returncode or 0)
83+
return RunnerResult(
84+
proc.returncode == 0, text, proc.returncode or 0)
8585

8686

8787
def _opencode_argv(task: Task) -> list[str]:

‎src/sin_delegate/scheduler.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ def _resume_states(self) -> dict[str, TaskState]:
6464
states: dict[str, TaskState] = {}
6565
for tid in self.tasks:
6666
prev = persisted.get(tid)
67-
states[tid] = (TaskState.DONE if prev == TaskState.DONE
68-
else TaskState.PENDING)
67+
states[tid] = (
68+
TaskState.DONE if prev == TaskState.DONE
69+
else TaskState.PENDING)
6970
return states
7071

7172
def _circuit_open(self, states: dict[str, TaskState]) -> bool:

‎src/sin_delegate/worktree.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def merge_back(self) -> str:
6666

6767
def destroy(self, delete_branch: bool = True) -> None:
6868
_git(self.repo, "worktree", "remove", "--force",
69-
str(self.path), check=False)
69+
str(self.path), check=False)
7070
if delete_branch:
7171
_git(self.repo, "branch", "-D", self.branch, check=False)
7272

‎tests/test_delegate.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def test_scheduler_resume_skips_done(tmp_path):
6363
ledger.register_run(plan.id, plan.goal, "{}")
6464
ledger.emit(plan.id, "A", "state:done")
6565
calls = []
66+
6667
async def executor(task):
6768
calls.append(task.id)
6869
return TaskOutcome(task.id, TaskState.DONE)

‎tests/test_intelligence_multirepo.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from sin_delegate.policy import Policy
2525
from sin_delegate.resolution import apply_resolutions
2626

27+
2728
# --------------------------------------------------------------- analytics
2829

2930
def test_wilson_punishes_small_samples():
@@ -154,8 +155,8 @@ def test_resolve_requires_input_for_retry(tmp_path):
154155
esc = broker.raise_escalation(
155156
"p1", "T1", "t", EscalationKind.GATE_FAILURE, "x", {})
156157
assert not broker.resolve("p1", esc.id, "retry")["ok"]
157-
assert broker.resolve("p1", esc.id, "retry",
158-
user_input="fix")["ok"]
158+
assert broker.resolve(
159+
"p1", esc.id, "retry", user_input="fix")["ok"]
159160

160161

161162
def test_resolve_is_idempotent(tmp_path):
@@ -168,8 +169,9 @@ def test_resolve_is_idempotent(tmp_path):
168169

169170
def test_apply_resolutions_drop_yields_pending_or_skipped(tmp_path):
170171
ledger = Ledger(tmp_path / "l.db")
171-
plan = Plan(goal="g", repo=".",
172-
tasks=(Task(title="t", instructions="x", id="T1"),))
172+
plan = Plan(
173+
goal="g", repo=".",
174+
tasks=(Task(title="t", instructions="x", id="T1"),))
173175
broker = EscalationBroker(ledger)
174176
ledger.register_run(plan.id, "g", json.dumps({
175177
"goal": "g", "tasks": [{"id": "T1", "title": "t"}]}))

0 commit comments

Comments
 (0)