Title: get_type_hints() fails on TypedDict inheriting from a generic TypedDict under PEP 563 · Issue #138949 · python/cpython · GitHub
Open Graph Title: get_type_hints() fails on TypedDict inheriting from a generic TypedDict under PEP 563 · Issue #138949 · python/cpython
X Title: get_type_hints() fails on TypedDict inheriting from a generic TypedDict under PEP 563 · Issue #138949 · python/cpython
Description: Bug report Bug description: This fails: from __future__ import annotations import typing class TD1[T](typing.TypedDict): a: T class TD2(TD1): pass print(typing.get_type_hints(TD2)) $ uv run --python=3.13 sample3.py Traceback (most recent...
Open Graph Description: Bug report Bug description: This fails: from __future__ import annotations import typing class TD1[T](typing.TypedDict): a: T class TD2(TD1): pass print(typing.get_type_hints(TD2)) $ uv run --pytho...
X Description: Bug report Bug description: This fails: from __future__ import annotations import typing class TD1[T](typing.TypedDict): a: T class TD2(TD1): pass print(typing.get_type_hints(TD2)) $ uv run --pytho...
Opengraph URL: https://github.com/python/cpython/issues/138949
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"get_type_hints() fails on TypedDict inheriting from a generic TypedDict under PEP 563","articleBody":"# Bug report\n\n### Bug description:\n\nThis fails:\n\n```python\nfrom __future__ import annotations\nimport typing\nclass TD1[T](typing.TypedDict):\n a: T\n\nclass TD2(TD1):\n pass\n\nprint(typing.get_type_hints(TD2))\n```\n\n```\n$ uv run --python=3.13 sample3.py \nTraceback (most recent call last):\n File \"/Users/jelle/py/cpython/sample3.py\", line 9, in \u003cmodule\u003e\n print(typing.get_type_hints(TD2))\n ~~~~~~~~~~~~~~~~~~~~~^^^^^\n File \"/opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/typing.py\", line 2461, in get_type_hints\n value = _eval_type(value, base_globals, base_locals, base.__type_params__)\n File \"/opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/typing.py\", line 474, in _eval_type\n return t._evaluate(globalns, localns, type_params, recursive_guard=recursive_guard)\n ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/typing.py\", line 1081, in _evaluate\n eval(self.__forward_code__, globalns, localns),\n ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\nNameError: name 'T' is not defined\n```\n\nAlso reproduces on 3.12 and on the latest RC of 3.14.\n\n(Got here while investigating https://github.com/python/cpython/issues/137226#issuecomment-3275500742, but since this variant is a longstanding bug we don't need to fix it for 3.14.0. I want to record and eventually fix it though.)\n\n### CPython versions tested on:\n\nCPython main branch, 3.15, 3.14, 3.13, 3.12\n\n### Operating systems tested on:\n\nmacOS","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2025-09-15T18:39:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/138949/cpython/issues/138949"}
| 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:82a0f284-45fa-bcda-a6dd-0b6e340e47cc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1CC:2C3E22:15FF77E:1C72180:696B2273 |
| html-safe-nonce | 0bc28fa24d9eab93bf91e40c62a42ca11a695729eaa3b9081d616b0d3b4b48c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUNDOjJDM0UyMjoxNUZGNzdFOjFDNzIxODA6Njk2QjIyNzMiLCJ2aXNpdG9yX2lkIjoiODYwOTAwOTUyMjc4MjcwODMzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a8e8a2c954e7a06b8d016a20cf629bb0390cd9571d9b0dc9a29304a0543de3bb |
| hovercard-subject-tag | issue:3419074269 |
| 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/138949/issue_layout |
| twitter:image | https://opengraph.githubassets.com/022af9aa6e272a699cbd8744f0563f52c93d1051e31310ae95a9283a21e06fd2/python/cpython/issues/138949 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/022af9aa6e272a699cbd8744f0563f52c93d1051e31310ae95a9283a21e06fd2/python/cpython/issues/138949 |
| og:image:alt | Bug report Bug description: This fails: from __future__ import annotations import typing class TD1[T](typing.TypedDict): a: T class TD2(TD1): pass print(typing.get_type_hints(TD2)) $ uv run --pytho... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width