Skip to content

Replace permission and renderer Any with concrete contracts - #1145

Merged
trissim merged 1 commit into
mainfrom
next/toad-types-02
Oct 23, 2026
Merged

trissim merged 1 commit into
mainfrom
next/toad-types-02

Conversation

@trissim

@trissim trissim commented Oct 23, 2026

Copy link
Copy Markdown

Replace four explicit Any uses with their actual contracts across six production modules. Permission callbacks return None; render-worker positional arguments preserve their types with a variadic generic; ui_theme paint produces Strip or Content. Cursor movement uses the existing CursorDirection parent, and cursor-presentation callbacks take BlockCursor. The conversation's reactive project path now declares the Path its constructor supplies.

Pipeline: autotyping 24.9.0 --aggressive, then Pyrefly 1.4.0 infer (-j 1, parameter/import inference; return/container inference off), followed by the full-production Pyrefly check. Corrected bad inferred bool callbacks and the UpCursor | DownCursor union. paint_text ignores its target and accepts Strip | None, preserving its current None callers and the backend's Strip contract.

Counts, from independent main b971751 (this branch does not include #1144):

  • Six-file batch: unannotated parameters 47 -> 38; explicit Any 9 -> 5.
  • Whole src/toad: unannotated parameters 2,174 -> 2,165; explicit Any 14 -> 10.
  • Full-production checker: 1,338 -> 1,333 errors; zero new diagnostics by path/code/description multiplicity. Existing checker errors remain errors.
  • Every touched module imported under python -I with this source and Core main 051fe6b617 first on sys.path; each compiled with compileall. All checks run nice -n 19. No pytest; tests/ unchanged.

Explicit Any stops (all ten remaining Name nodes):

  • src/toad/acp/comms_updates.py:266: PendingThreadRead.agent is the concrete ACP Agent, whose module imports this consumer before declaring Agent. AgentBase does not declare the required coordination/controller contract. No circular import, TYPE_CHECKING workaround or fake base annotation added.
  • src/toad/render_processes.py:65,83: pending futures carry heterogeneous job results. Future[object] or an unparameterized Future would conceal the missing result-independent completion contract; both are rejected.
  • src/toad/textual_colours.py:445: the cooperative themed-app constructor forwards Textual App's positional/keyword constructor contract. Removing its variadic types would merely turn explicit Any into implicit Any.
  • src/toad/preferences.py:390,403: the settings encoder recursively selects dictionaries through schema-owned descendant information. A JsonValue union alone cannot establish that an indexed descendant is a mapping; no cast, primitive type switch or object replacement added.
  • src/toad/version.py:56,79: run_thread is a higher-rank generic callback used for both Version and AsyncClient constructors. A return union loses argument/result correlation. No Protocol or Any alias added.

Assumed:

  • The production permission callback (agent_surface.py) returns None; provider/test substitutes remain untouched.
  • A union of external paint value types is legitimate; a union of our cursor subclasses is replaced by their declared parent.
  • Existing type-checker failures are used to identify introduced errors, not called a passing checker run.

Apply checked inference to conversation parameters and boundary returns. Preserve positional argument types through render-worker submission with a variadic generic. Use the existing CursorDirection parent, None-returning permission callbacks, and the actual external paint result types. Type the conversation path as the Path its constructor supplies.
@trissim
trissim marked this pull request as ready for review October 23, 2026 10:54
Copilot AI balanced review requested due to automatic review settings October 23, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@trissim
trissim merged commit 200e334 into main Oct 23, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants