fix(types): sweep invalid-parameter-default across core modules

Add `| None` to ~250 params across 30 files that were annotated as bare
`str`, `list`, `dict`, `int`, `Callable`, etc. but defaulted to None.

This is a big typechecking fix. each one cascades, making ty stop
narrowing those vars to None and clearing downstream
unresolved-attribute / not-subscriptable / invalid-argument-type errors.

Two type bugs surfaced and fixed during the sweep:

1. Lowercase `callable` (builtin function) used as type annotation in
   28 callback params in agent_init.py + run_agent.py. `callable | None`
   isn't valid. Fixed to `Callable` (typing).

2. String forward-ref with `| None` (`"IterationBudget" | None`) is
    wrong because `|` can't OR a str with NoneType. Fixed to
   `Optional["IterationBudget"]`.

Also:
- Configure ty to exclude tests/ via [tool.ty.src] in pyproject.toml
  (tests are ~57% of diagnostics, lowest-value typing target)

ty diagnostics: 13,290 -> 4,648 (core only, tests excluded)
Tests: 496 passed, 0 failed
This commit is contained in:
ethernet 2026-07-17 14:52:29 -04:00
parent cfb9459cc8
commit 169bfe20e4
32 changed files with 494 additions and 313 deletions

View file

@ -869,7 +869,7 @@ def _build_child_progress_callback(
return kw
def _relay(
event_type: str, tool_name: str = None, preview: str = None, args=None, **kwargs
event_type: str, tool_name: str | None = None, preview: str = None, args=None, **kwargs
):
if not parent_cb:
return