Skip to content

[codex] narrow template helper types - #162

Merged
lbliii merged 1 commit into
mainfrom
codex/reduce-helper-any
Jul 7, 2026
Merged

[codex] narrow template helper types#162
lbliii merged 1 commit into
mainfrom
codex/reduce-helper-any

Conversation

@lbliii

@lbliii lbliii commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • refresh the template-helper Any RFC against the current source tree
  • replace provably arbitrary helper parameters and returns with object
  • mark the undefined-error helper as Never
  • preserve profiling pass-through types with PEP 695 generics
  • leave dynamic contexts, generated-call boundaries, namespace dictionaries, and unchecked subscript casts unchanged

Why

The RFC's old counts predated substantial runtime growth and no longer described the implementation. Internal helper contracts were also using Any where a precise arbitrary-value or never-returning contract was available.

Impact

This is type-only runtime refactoring. Helper behavior and public template context APIs are unchanged. The lexical Any count drops from 36 to 19 in template/helpers.py and from 658 to 641 across src/kida.

Validation

  • make lint
  • make ty
  • make format-check
  • 218 focused strict/nullish/operator/environment/render-context tests
  • make test (4,280 passed, 5 skipped)

Steward Notes

  • Consulted: Template Runtime, Environment, Static Analysis, Planning, and Test Corpus stewards.
  • Risk: helper annotations are internal compiler/runtime contracts; generated render behavior must remain unchanged.
  • Evidence: full runtime suite, focused strict/optional behavior tests, and clean ty output.
  • No collateral: no public signature, rendering behavior, dependency, or benchmark claim changed; no hot-path instructions changed.

Closes #146.

@lbliii
lbliii marked this pull request as ready for review July 7, 2026 14:33
Copilot AI review requested due to automatic review settings July 7, 2026 14:33
@lbliii
lbliii merged commit bddb2da into main Jul 7, 2026
11 checks passed
@lbliii
lbliii deleted the codex/reduce-helper-any branch July 7, 2026 14:35

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.

Pull request overview

This PR tightens internal template runtime helper type annotations to reduce Any usage (without changing runtime behavior), and refreshes the companion RFC with updated baseline counts and status.

Changes:

  • Narrow helper contracts in src/kida/template/helpers.py by replacing provably-arbitrary Any with object, marking the strict undefined helper as Never, and preserving profiling pass-through types with PEP 695 generics.
  • Update plan/rfc-template-helpers-any-reduction.md to Active and record refreshed lexical Any baselines/success metrics for the #146 slice.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/kida/template/helpers.py Narrows helper annotations (Anyobject, Never for never-returning helper, generics for pass-through profiling).
plan/rfc-template-helpers-any-reduction.md Refreshes RFC status and baseline counts / success criteria for the Any reduction slice.

Comment on lines +39 to +43
- `_raise_undefined_attr()` returns `Never`;
- `markup_concat()`, `coerce_numeric()`, lazy default/defined/coalescing helpers,
and `optional_call()` accept or return `object` where values are arbitrary;
- profiling pass-through helpers use a generic type so their result type is
preserved;
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.

Execute the Template Helpers Any Reduction RFC against current code

2 participants