Skip to content

Schema inference: resolve string annotations, Annotated and NewType (#27) - #28

Merged
thorwhalen merged 2 commits into
masterfrom
fix/27-infer-annotations
Oct 13, 2026
Merged

thorwhalen merged 2 commits into
masterfrom
fix/27-infer-annotations

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Closes #27.

  • resolve_annotations(func, parameters) (ju.util): evaluates string annotations via typing.get_type_hints (partials, callable instances, bound methods, classes), falling back to per-parameter eval; unresolvable ones are left as-is. Used by signature_to_json_schema.
  • unwrap_optional also peels Annotated, NewType and type X = ... aliases (top level and union members), which feeds is_type and array items.
  • Array items inference now hands a custom param_to_prop_type a Parameter carrying the owning parameter's real name (was _).
  • Tests in ju/tests/annotations_test.py (under from __future__ import annotations).

Review: fresh Opus reviewer: fix-then-merge. Confirmed and fixed: a recursive type alias crashed with RecursionError (items nesting now bounded), a cycle of aliases looped forever (now detected), a class defining only __new__ kept string annotations (now resolved). Tests added for each.

🤖 Generated with Claude Code

Dependents gate: 11 pass, 1 fail (smart-cv, collection errors, pre-existing).

thorwhalen and others added 2 commits October 13, 2026 15:38
…name item params (#27)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…efining only __new__ (#27)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 78b8a16 into master Oct 13, 2026
8 checks passed
@thorwhalen
thorwhalen deleted the fix/27-infer-annotations branch October 13, 2026 15:43
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.

Schema inference: resolve string annotations, Annotated and NewType; give item params their real name

1 participant