You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
source-control: babysit_util type-check helpers should be TypeGuards, deleting ~12 casts in merge/gh #3448
agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.status: readyTriaged, unblocked, and fully specified; eligible to pick up.
Found by the repo-wide /code-tidying:batch-simplify sweep (62 groups / 986 files, branch claude/repo-code-tidying-batch-twhddw). Deferred from the sweep as dedicated-PR-shaped work: the consolidation crosses file or contract boundaries a behavior-preserving sweep must not cross.
plugins/source-control/skills/babysit-prs/scripts/babysit_util.py:29 — converting the is_* helpers to TypeGuard returns deletes ~12 casts in babysit_merge/babysit_gh. One-diff change owned by the util module.
Proposed work
Convert to typing.TypeGuard and drop the now-redundant casts.
Acceptance criteria
mypy/pyright clean with the casts removed; test suite green.
Claim holds, and the payoff is larger than filed. The type-check helpers in the babysit utility module still return plain booleans, so a caller learns nothing about the value's type from calling them and must cast afterwards. The cast count has grown: the merge module now carries 17 cast sites, against the roughly 12 the body estimated. One correction to scope: the body names both the merge and the gh modules as beneficiaries, but the gh module currently has no casts, so the deletions land in the merge module.
Agent Brief
Type: Task (refactor)
Summary: Convert the babysit utility module's type-check predicates to type guards so callers narrow the value directly and the redundant casts disappear.
Current behavior:
The utility module exposes predicates that answer whether a decoded JSON value is an object or an array, returning a plain boolean. Because the return type carries no narrowing information, every caller that acts on a true result must add a cast to tell the type checker what the predicate already proved. Those casts are pure ceremony: they restate a fact the predicate established, and each one is a place where a wrong type could be asserted without the checker objecting.
Desired behavior:
The predicates return a type guard, so a true result narrows the value at the call site. The casts that existed only to restate the predicate's result are deleted. No runtime behavior changes: the predicates test the same conditions and return the same values.
Key interfaces:
The babysit utility module's JSON type-check predicates, whose return annotations change from a plain boolean to a type guard over the narrowed type.
Their callers in the babysit merge module, where the redundant casts are removed.
Acceptance criteria:
The type-check predicates return type guards.
Casts made redundant by the narrowing are deleted; no cast remains that only restates a predicate result.
The repository's configured Python type checker passes with the casts removed.
The babysit test suite is green, and no runtime behavior changes.
scripts/affected-tests.sh --run passes for the touched surfaces.
Out of scope:
Any other change to the babysit utility module or to the merge module's logic.
Introducing type guards elsewhere in the plugin.
The guarded-mutation preamble consolidation tracked separately in the same script family.
agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.status: readyTriaged, unblocked, and fully specified; eligible to pick up.
Activity
claude commentedon Sep 6, 2026
Generated by Claude Code
claude commentedon Sep 6, 2026
This was generated by AI during triage.
Triage verification (2026-09-06)
Claim holds, and the payoff is larger than filed. The type-check helpers in the babysit utility module still return plain booleans, so a caller learns nothing about the value's type from calling them and must cast afterwards. The cast count has grown: the merge module now carries 17 cast sites, against the roughly 12 the body estimated. One correction to scope: the body names both the merge and the gh modules as beneficiaries, but the gh module currently has no casts, so the deletions land in the merge module.
Agent Brief
Type: Task (refactor)
Summary: Convert the babysit utility module's type-check predicates to type guards so callers narrow the value directly and the redundant casts disappear.
Current behavior:
The utility module exposes predicates that answer whether a decoded JSON value is an object or an array, returning a plain boolean. Because the return type carries no narrowing information, every caller that acts on a true result must add a cast to tell the type checker what the predicate already proved. Those casts are pure ceremony: they restate a fact the predicate established, and each one is a place where a wrong type could be asserted without the checker objecting.
Desired behavior:
The predicates return a type guard, so a true result narrows the value at the call site. The casts that existed only to restate the predicate's result are deleted. No runtime behavior changes: the predicates test the same conditions and return the same values.
Key interfaces:
Acceptance criteria:
scripts/affected-tests.sh --runpasses for the touched surfaces.Out of scope:
Generated by Claude Code