Skip to content

fix: support TypedDict schema generation#2978

Merged
michaeldwan merged 5 commits intomainfrom
2973/typeddict
Apr 30, 2026
Merged

fix: support TypedDict schema generation#2978
michaeldwan merged 5 commits intomainfrom
2973/typeddict

Conversation

@markphelps
Copy link
Copy Markdown
Contributor

@markphelps markphelps commented Apr 29, 2026

Fixes: #2973

Summary

  • fix legacy runtime schema generation so TypedDict inputs are treated like dicts without accepting arbitrary dict subclasses
  • add static schema support for TypedDict inputs and outputs, including qualified imports, inheritance, and Required / NotRequired key semantics
  • add regression coverage in Python, Go parser tests, and integration txtar scripts for static and legacy TypedDict paths

Notes

  • added integration txtar coverage for typeddict_input, typeddict_input_legacy, and typeddict_output

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

This PR adds comprehensive TypedDict support for both static schema generation (Go parser) and legacy runtime schema generation (Python ADT). The implementation correctly handles:

  • TypedDict inputs treated as opaque dicts (ANY type)
  • TypedDict outputs with proper field extraction
  • Required/NotRequired field qualifiers
  • TypedDict inheritance (parent classes)
  • Cross-file TypedDict imports
  • total=False semantics

All Go tests pass. The integration test coverage is excellent with three txtar scripts covering static input, legacy input, and output paths.

One minor issue found:

Comment thread pkg/schema/types.go Outdated
Comment thread pkg/schema/python/parser.go Outdated
Comment thread pkg/schema/python/parser.go Outdated
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 29, 2026

I've posted a review on PR #2978 identifying one minor issue where qualifiedEntry is assigned but never used in the error handling code at pkg/schema/types.go:320. The review is now visible on the PR.

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 29, 2026

LGTM

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 29, 2026

Looking at PR #2978 which adds TypedDict support for both static schema generation (Go parser) and legacy runtime schema generation (Python ADT), I can see the implementation is comprehensive and well-tested.

From the context provided, I can see that:

  1. A previous review already identified and addressed the qualifiedEntry issue in pkg/schema/types.go
  2. The author acknowledged the parameter count concern for some functions

The implementation correctly handles:

  • TypedDict inputs treated as opaque dicts (ANY type)
  • TypedDict outputs with proper field extraction
  • Required/NotRequired field qualifiers
  • TypedDict inheritance (parent classes)
  • Cross-file TypedDict imports
  • total=False semantics

All Go tests pass and the integration test coverage includes three txtar scripts. The Python ADT changes properly check for TypedDict using typing.is_typeddict.

LGTM

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 29, 2026

LGTM

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 30, 2026

LGTM

github run

@markphelps markphelps marked this pull request as ready for review April 30, 2026 14:11
@markphelps markphelps requested a review from a team as a code owner April 30, 2026 14:11
@markphelps markphelps requested a review from michaeldwan April 30, 2026 14:11
Copy link
Copy Markdown
Member

@michaeldwan michaeldwan left a comment

Choose a reason for hiding this comment

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

nice fix

@michaeldwan michaeldwan added this pull request to the merge queue Apr 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 30, 2026
@michaeldwan michaeldwan added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit 7e613e6 Apr 30, 2026
43 checks passed
@michaeldwan michaeldwan deleted the 2973/typeddict branch April 30, 2026 16:20
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 generation does not handle TypedDict as dict

2 participants