chore(types): mypy strict for locus.loop.* + locus.reasoning.* (#34 batch 4)#46
Merged
Conversation
…batch 4) Lifts ``locus.loop.*`` (~1.3k LOC across runner / router / nodes / react) and ``locus.reasoning.*`` (~3k LOC across causal / gsar / gsar_judge / gsar_evaluator / grounding / reflexion) out of the mypy ``ignore_errors`` blanket so they are now type-checked under the project's strict defaults. Specific fixes: - ``reasoning.causal._detect_bidirectional``: build the pair tuple with explicit ``(str, str)`` typing so ``set[tuple[str, str]].add`` type-checks (was inferred as the wider ``tuple[str, ...]``). - ``reasoning.gsar_judge.StructuredOutputGSARJudge.judge``: cast the ``StructuredOutput.parsed`` field (typed as ``BaseModel | None``) back to ``JudgeOutput`` since the dynamic type is pinned by the schema we passed to ``parse_structured``. - ``loop.router.RouterWithCustomConditions.route``: bind the ``model_copy`` result to a ``RouteDecision`` local so the return isn't ``Any``. - ``loop.nodes.ToolNode``: declare the local ``events`` list with the same union as ``NodeResult.events`` so ``list``-invariance doesn't reject the otherwise-correct return. - ``loop.runner``: drop a stale ``# type: ignore[assignment]``. ``locus.hooks.builtin.*`` is intentionally held back. The migration surfaces a real correctness gap — the built-in hooks (LoggingHook / GuardrailsHook / TelemetryHook) carry method signatures from a pre-event ``HookProvider`` API and would TypeError when dispatched through ``HookRegistry.emit_*``. That is a behavioural fix and is tracked on its own follow-up PR. Remaining batches: ``locus.rag.*``, ``locus.memory.*``, ``locus.hooks.builtin.*``. Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
This was referenced May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lifts two more module groups out of the mypy
ignore_errorsblanket:locus.loop.*(~1.3k LOC: runner, router, nodes, react)locus.reasoning.*(~3k LOC: causal, gsar, gsar_judge, gsar_evaluator, grounding, reflexion)After this lands, only three groups remain on
ignore_errors:locus.rag.*locus.memory.*locus.hooks.builtin.*(held back — see below)Notable: held-back module surfaces a real bug
While running the strict pass over
locus.hooks.builtin.*, mypy surfaced that the built-in hooks (LoggingHook,GuardrailsHook,TelemetryHook) have method signatures inherited from a pre-eventHookProviderAPI — they wouldTypeErrorat runtime when dispatched throughHookRegistry.emit_*.That's a behavioural fix, not a typing one. Tracked in #45 and migrated in a follow-up PR. Only the typing blanket on that one subpackage is preserved here — the rest of the audit goal is unaffected.
Test plan
hatch run typecheck— clean (150 source files)hatch run test— 3,246 passedpre-commit run --all-files— clean