Skip to content

Preserve TypedDict annotations on Python 3.14 - #77

Open
saitakarcesme wants to merge 1 commit into
python:masterfrom
saitakarcesme:codex/typeddict-python314-annotations
Open

saitakarcesme wants to merge 1 commit into
python:masterfrom
saitakarcesme:codex/typeddict-python314-annotations

Conversation

@saitakarcesme

Copy link
Copy Markdown

Fixes #65.

On Python 3.14, class-based TypedDict annotations are deferred, so reading only the class namespace loses the declared fields. Reading inherited annotations from base.__dict__ also misses annotations stored by the type descriptor. Use annotationlib.get_annotations(..., FORWARDREF) on 3.14 and retrieve base annotations through attribute access, preserving the older-Python path and the existing functional/keyword syntaxes.

The regression tests cover local types, inheritance, invalid annotations, quoted and deferred self references, and future annotations. Add 3.14 to the test matrix and tox environments.

Validation: the existing inheritance test and three added regressions fail on the unchanged implementation under Python 3.14. With the fix, python -We -m unittest discover tests passes all 17 tests on Python 3.14.6; Python 3.13 passes 16 with the 3.14-only test skipped. Flake8 and git diff --check pass.

AI disclosure: this patch, tests, and description were prepared with OpenAI Codex; the commands above were executed locally.

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.

test_py36_class_syntax_usage fails on py 3.14.0a6

1 participant