Skip to content

Infer array 'items' and recognise annotation-only list params (#19) - #26

Merged
thorwhalen merged 2 commits into
masterfrom
fix/array-schema-inference-19
Oct 13, 2026
Merged

thorwhalen merged 2 commits into
masterfrom
fix/array-schema-inference-19

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Closes #19.

  • is_type now matches an annotation (bare, subscripted, Optional/| union) against a type or its subclasses, so x: list[int], x: list, x: dict[str, int] no longer fall back to 'string'. A subscripted mapping entry (Sequence[str]) needs identical args, so bytes-like and str annotations stay 'string'.
  • get_properties adds items to array params: from the annotation's single argument (list[int], tuple[int, ...], nested list[list[str]]), else from the default's elements when they all share one JSON type. Heterogeneous/empty defaults and tuple[int, str] get no items.

Known limits (unchanged): string annotations (from __future__ import annotations), Annotated, NewType still give 'string'. Custom type mappings listing a parent before its child now also apply that order to annotations. A custom param_to_prop_type sees items as a parameter named _.

Adversarial review (fresh Opus): fix-then-merge. Confirmed bytes/bytearray/memoryview/UserString annotations flipping to 'array': fixed + test. Protocol-with-data-members issubclass TypeError: guarded. Gate (priv test-dependents ju --transitive): 11 pass, 1 fail (smart-cv, pre-existing collection error).

🤖 Generated with Claude Code

thorwhalen and others added 2 commits October 13, 2026 14:10
…ature schemas (#19)

is_type now matches an annotation (bare, subscripted or Optional) against a type or
its subclasses; get_properties adds 'items' from the annotation's argument, else from
a homogeneous default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d matching args (#19 review)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 329e9ea into master Oct 13, 2026
8 checks passed
@thorwhalen
thorwhalen deleted the fix/array-schema-inference-19 branch October 13, 2026 14:13
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.

Schemas inferred from a live signature: annotation-only list params fall back to 'string', and arrays carry no 'items'

1 participant