Skip to content

fix: support typing_extensions TypedDict at runtime#2983

Merged
markphelps merged 3 commits into
mainfrom
fix-typing-extensions-typeddict-runtime
May 1, 2026
Merged

fix: support typing_extensions TypedDict at runtime#2983
markphelps merged 3 commits into
mainfrom
fix-typing-extensions-typeddict-runtime

Conversation

@markphelps
Copy link
Copy Markdown
Collaborator

Summary

  • Prefer typing_extensions.is_typeddict when detecting dict-like annotations in the legacy runtime schema path.
  • Add regression coverage for typing_extensions.TypedDict inputs, including list/optional forms.
  • Update the legacy TypedDict integration fixture to exercise typing_extensions.TypedDict.

Tests

  • .venv/bin/python -m pytest python/tests/test_adt.py -q
  • mise run lint:python

Fixes the runtime/legacy half of #2973 follow-up; third-party TypedDicts in the static Go parser remain a separate issue.

@markphelps markphelps requested a review from a team as a code owner May 1, 2026 17:42
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

LGTM

github run

Comment thread python/cog/_adt.py

if is_typeddict_ext(tpe):
return True
except ImportError:
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.

The changes look good overall - adding typing_extensions.TypedDict support with proper fallback and comprehensive tests. One minor issue to address:

Comment thread python/cog/_adt.py
if is_typeddict_ext(tpe):
return True
except ImportError:
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Empty except clause without explanatory comment. Please add a comment explaining that typing_extensions is optional and the function falls back to typing.is_typeddict below.

Suggested change
pass
except ImportError:
# typing_extensions is optional; fall back to typing.is_typeddict below
pass

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

Posted a review on PR #2983. The changes add proper runtime support for typing_extensions.TypedDict with good test coverage. There's one minor issue flagged about the empty except clause needing a comment to document the fallback intent.

github run

michaeldwan
michaeldwan previously approved these changes May 1, 2026
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps merged commit 4269575 into main May 1, 2026
25 of 26 checks passed
@markphelps markphelps deleted the fix-typing-extensions-typeddict-runtime branch May 1, 2026 18:09
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

fatal: couldn't find remote ref fix-typing-extensions-typeddict-runtime

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

@markphelps Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@markphelps markphelps mentioned this pull request May 1, 2026
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