Title: `get_type_hints` fails for `dataclass` in 3.14 · Issue #144190 · python/cpython · GitHub
Open Graph Title: `get_type_hints` fails for `dataclass` in 3.14 · Issue #144190 · python/cpython
X Title: `get_type_hints` fails for `dataclass` in 3.14 · Issue #144190 · python/cpython
Description: Bug report Bug description: This code works in 3.13, but fails in 3.14: from dataclasses import dataclass from typing import get_type_hints @dataclass class MyHintedClass: my_attr: int = 1 def __init__(self): self.hints = get_type_hints(...
Open Graph Description: Bug report Bug description: This code works in 3.13, but fails in 3.14: from dataclasses import dataclass from typing import get_type_hints @dataclass class MyHintedClass: my_attr: int = 1 def __in...
X Description: Bug report Bug description: This code works in 3.13, but fails in 3.14: from dataclasses import dataclass from typing import get_type_hints @dataclass class MyHintedClass: my_attr: int = 1 def __in...
Opengraph URL: https://github.com/python/cpython/issues/144190
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`get_type_hints` fails for `dataclass` in 3.14","articleBody":"# Bug report\n\n### Bug description:\n\nThis code works in 3.13, but fails in 3.14:\n```python\nfrom dataclasses import dataclass\nfrom typing import get_type_hints\n\n\n@dataclass\nclass MyHintedClass:\n my_attr: int = 1\n\n def __init__(self):\n self.hints = get_type_hints(self)\n\n\nmy_class = MyHintedClass()\nprint(my_class.hints)\n```\nFailure in 3.14:\n```shell\n~\\py\\pybug: uv run --python=3.14 python main.py \nTraceback (most recent call last):\n File \"C:\\Users\\bfrandeen\\py\\pybug\\main.py\", line 13, in \u003cmodule\u003e\n my_class = MyHintedClass()\n File \"C:\\Users\\bfrandeen\\py\\pybug\\main.py\", line 10, in __init__\n self.hints = get_type_hints(self)\n ~~~~~~~~~~~~~~^^^^^^\n File \"C:\\Users\\bfrandeen\\AppData\\Roaming\\uv\\python\\cpython-3.14.2-windows-x86_64-none\\Lib\\typing.py\", line 2401, in get_type_hints\n hints = _lazy_annotationlib.get_annotations(obj, format=format)\n File \"C:\\Users\\bfrandeen\\AppData\\Roaming\\uv\\python\\cpython-3.14.2-windows-x86_64-none\\Lib\\annotationlib.py\", line 996, in get_annotations\n raise TypeError(f\"{obj!r} does not have annotations\")\nTypeError: MyHintedClass(my_attr=1) does not have annotations\n```\nWorks in older versions:\n```shell\n~\\py\\pybug: uv run --python=3.13 python main.py\nUsing CPython 3.13.2\nRemoved virtual environment at: .venv\nCreating virtual environment at: .venv\nInstalled 6 packages in 190ms\n{'my_attr': \u003cclass 'int'\u003e}\n```\n\n### CPython versions tested on:\n\n3.14, 3.13\n\n### Operating systems tested on:\n\nWindows, Linux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-144831\n* gh-145258\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/bfrandeen","@type":"Person","name":"bfrandeen"},"datePublished":"2026-01-23T17:53:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/144190/cpython/issues/144190"}
| 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:8783dc8a-e18e-71b8-555f-b64ef42224d8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8672:2086C7:735126C:A249D0E:6A500E85 |
| html-safe-nonce | e96e48a0403233859877658fc5ca067949262c06c8df1e673662b737ead71477 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjcyOjIwODZDNzo3MzUxMjZDOkEyNDlEMEU6NkE1MDBFODUiLCJ2aXNpdG9yX2lkIjoiOTA4Njg2MDMwODQ3NjA3MTU1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7a6fc55d6d013bc3be9e0cb4d2cfe48c53701e0b77542c2eda6cb173ff04ad7c |
| hovercard-subject-tag | issue:3848523558 |
| 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/144190/issue_layout |
| twitter:image | https://opengraph.githubassets.com/132d72871969744a745f17be20c4ce79d0d6bacaf51b1d42f296f7f38d42a46d/python/cpython/issues/144190 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/132d72871969744a745f17be20c4ce79d0d6bacaf51b1d42f296f7f38d42a46d/python/cpython/issues/144190 |
| og:image:alt | Bug report Bug description: This code works in 3.13, but fails in 3.14: from dataclasses import dataclass from typing import get_type_hints @dataclass class MyHintedClass: my_attr: int = 1 def __in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bfrandeen |
| hostname | github.com |
| expected-hostname | github.com |
| None | fe4f38b24922a1ce81c1708c3793b47c185599b9144ab94f6ca846b00698058d |
| 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 | 42b6390c91978a16f9196c38c7a00e9bf21f37e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width