Title: multi-level hierarchies of TypedDict no longer return superclass elements in __annotations__ as of 3.14.0b1 when future annotations enabled · Issue #133701 · python/cpython · GitHub
Open Graph Title: multi-level hierarchies of TypedDict no longer return superclass elements in __annotations__ as of 3.14.0b1 when future annotations enabled · Issue #133701 · python/cpython
X Title: multi-level hierarchies of TypedDict no longer return superclass elements in __annotations__ as of 3.14.0b1 when future annotations enabled · Issue #133701 · python/cpython
Description: Bug report Bug description: using get_annotations() or accessing __annotations__ directly on a TypedDict subclass previously returned a dictionary of all attributes in the TypedDict hierarchy, now only returns for the sub-most class. onl...
Open Graph Description: Bug report Bug description: using get_annotations() or accessing __annotations__ directly on a TypedDict subclass previously returned a dictionary of all attributes in the TypedDict hierarchy, now ...
X Description: Bug report Bug description: using get_annotations() or accessing __annotations__ directly on a TypedDict subclass previously returned a dictionary of all attributes in the TypedDict hierarchy, now ...
Opengraph URL: https://github.com/python/cpython/issues/133701
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"multi-level hierarchies of TypedDict no longer return superclass elements in __annotations__ as of 3.14.0b1 when future annotations enabled","articleBody":"# Bug report\n\n### Bug description:\n\nusing `get_annotations()` or accessing `__annotations__` directly on a `TypedDict` subclass previously returned a dictionary of all attributes in the TypedDict hierarchy, now only returns for the sub-most class. only happens when `from __future__ import annotations` is used; when not used, then it works as previously. there's no workaround here because the typeddict subclass does not include declared superclasses in its `__mro__`. \n\n```python\nfrom __future__ import annotations\n\nfrom typing import TypedDict\n\nimport annotationlib\n\nclass Base(TypedDict,total=False):\n a: int\n b: int\n\nclass Sub(Base,total=False):\n c: float\n d: int\n\n# for both, py3.14.0a7 has all four, py3.14.0b1 has only c, d\n# py3.14.0a7: {'a': ForwardRef('int', module='__main__'), 'b': ForwardRef('int', module='__main__'), 'c': ForwardRef('float', module='__main__'), 'd': ForwardRef('int', module='__main__')}\n# py3.14.0b1: {'c': 'float', 'd': 'int'}\n\nprint(Sub.__annotations__)\nprint(annotationlib.get_annotations(Sub))\n\n# there's no way to traverse the ``__mro__`` of the Sub class to find\n# these annotations since Base is not there; prints\n# (\u003cclass '__main__.Sub'>, \u003cclass 'dict'>, \u003cclass 'object'>)\nprint(Sub.__mro__)\n\n\n```\n\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-133772\n* gh-134003\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/zzzeek","@type":"Person","name":"zzzeek"},"datePublished":"2025-05-08T19:13:41Z","url":"https://github.com/python/cpython/issues/133701"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fd558def-c840-0818-1d9e-003600c51a99 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9618:3A13A0:279599C:35C3B6A:6B0042A2 |
| html-safe-nonce | f1935ab1a6fac158978a07be5020a2297d8a2f78197653de442f7a6efc9231ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjE4OjNBMTNBMDoyNzk1OTlDOjM1QzNCNkE6NkIwMDQyQTIiLCJ2aXNpdG9yX2lkIjoiNTMxNjMxNDU0OTQ2MzMwMjgxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ea45b3a6a60f2d1d02d622704d2a0f4846d402034345f48c886ffaf38dfdbcb7 |
| hovercard-subject-tag | issue:3049872036 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/133701/issue_layout |
| twitter:image | https://opengraph.githubassets.com/303cd8740a2237e80e68b845e66c3cb922ae628c3a17d3f4931613836bc078f3/python/cpython/issues/133701 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/303cd8740a2237e80e68b845e66c3cb922ae628c3a17d3f4931613836bc078f3/python/cpython/issues/133701 |
| og:image:alt | Bug report Bug description: using get_annotations() or accessing __annotations__ directly on a TypedDict subclass previously returned a dictionary of all attributes in the TypedDict hierarchy, now ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zzzeek |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width