Title: Calling help() on a dataclass shows dataclass internal names instead of type names in 3.14 or later · Issue #137530 · python/cpython · GitHub
Open Graph Title: Calling help() on a dataclass shows dataclass internal names instead of type names in 3.14 or later · Issue #137530 · python/cpython
X Title: Calling help() on a dataclass shows dataclass internal names instead of type names in 3.14 or later · Issue #137530 · python/cpython
Description: Bug report Bug description: If you call help on a dataclass in Python 3.14 or later it shows the internal type names used for the exec call in the signature. Docstring included to hide the dataclasses generated __doc__ which would just c...
Open Graph Description: Bug report Bug description: If you call help on a dataclass in Python 3.14 or later it shows the internal type names used for the exec call in the signature. Docstring included to hide the dataclas...
X Description: Bug report Bug description: If you call help on a dataclass in Python 3.14 or later it shows the internal type names used for the exec call in the signature. Docstring included to hide the dataclas...
Opengraph URL: https://github.com/python/cpython/issues/137530
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Calling help() on a dataclass shows dataclass internal names instead of type names in 3.14 or later","articleBody":"# Bug report\n\n### Bug description:\n\nIf you call `help` on a dataclass in Python 3.14 or later it shows the internal type names used for the exec call in the signature.\n\nDocstring included to hide the dataclasses generated `__doc__` which would just confuse things.\n\n```python\nfrom dataclasses import dataclass\n\n@dataclass\nclass Example:\n \"docstring\"\n x: int\n\nhelp(Example)\n```\n\nBefore, on 3.13\n```\nHelp on class Example in module __main__:\n\nclass Example(builtins.object)\n | Example(x: int) -\u003e None\n |\n | docstring\n |\n | Methods defined here:\n |\n | __eq__(self, other)\n | Return self==value.\n |\n | __init__(self, x: int) -\u003e None\n | Initialize self. See help(type(self)) for accurate signature.\n...\n```\n\nNow, on 3.14 or later\n```\nHelp on class Example in module __main__:\n\nclass Example(builtins.object)\n | Example(x: __dataclass_type_x__) -\u003e __dataclass___init___return_type__\n |\n | docstring\n |\n | Methods defined here:\n |\n | __eq__(self, other)\n | Return self==value.\n |\n | __init__(self, x: __dataclass_type_x__) -\u003e __dataclass___init___return_type__\n | Initialize self. See help(type(self)) for accurate signature.\n...\n```\n\nThis looks a bit messy and reveals inner details that users of `help` probably don't need to see.\n\nIt looks like this comes from `inspect.signature(cls, annotation_format=Format.STRING)` being used in pydoc, but I think it's a dataclasses issue.\n\n`attrs` doesn't suffer the same fate as it attaches annotations as `__annotations__` instead of defining them in the source code string to be evaluated.\n\nInspired by that, for my own dataclass-like implementation for 3.14+ I'm collecting the annotations and generating an `__annotate__` function which appears to solve this issue: [see here](https://github.com/DavidCEllis/ducktools-classbuilder/blob/57b6e651fdd8766a7d76f8ade82b2e0a41756c17/src/ducktools/classbuilder/annotations.py#L86-L113)\n\n`dataclasses` could potentially do something similar. \n\n### CPython versions tested on:\n\n3.14, CPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-137711\n* gh-141352\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/DavidCEllis","@type":"Person","name":"DavidCEllis"},"datePublished":"2025-08-07T19:35:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/137530/cpython/issues/137530"}
| 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:6fa4d4a5-4dad-5bec-71fc-99c1d25f9e90 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E086:26E090:26A7840:3526981:6964DB76 |
| html-safe-nonce | 9df9967a09559c3ed3b09c3fcb51f9165e17ed14dac1e3ae33c4cb1ebff12444 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDg2OjI2RTA5MDoyNkE3ODQwOjM1MjY5ODE6Njk2NERCNzYiLCJ2aXNpdG9yX2lkIjoiNDI5ODMyODkzMDAxNjA5MDk5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 67c496316db139fcd56e14151d04ce0e06f1990f4c194f1a17f6f19682626ca6 |
| hovercard-subject-tag | issue:3301656583 |
| 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/137530/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9525af7654053dc237adc3485040249b8945540be6c9227305c155e5f71fce11/python/cpython/issues/137530 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9525af7654053dc237adc3485040249b8945540be6c9227305c155e5f71fce11/python/cpython/issues/137530 |
| og:image:alt | Bug report Bug description: If you call help on a dataclass in Python 3.14 or later it shows the internal type names used for the exec call in the signature. Docstring included to hide the dataclas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DavidCEllis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5838582163a1256e5ebd5086b7e1dc5cea93d82086c9c8b1395fb50f6ddab28d |
| 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 | 8f997e7f84bd1db9537ba403fa68be0da3423594 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width