Title: dataclass, slots, __post_init__ and super · Issue #111500 · python/cpython · GitHub
Open Graph Title: dataclass, slots, __post_init__ and super · Issue #111500 · python/cpython
X Title: dataclass, slots, __post_init__ and super · Issue #111500 · python/cpython
Description: Bug report Bug description: Using super() in __post_init__ on a dataclass with slots fails. This code: from dataclasses import dataclass @dataclass(slots=True) class Base: def __post_init__(self): pass @dataclass(slots=True) class Thing(...
Open Graph Description: Bug report Bug description: Using super() in __post_init__ on a dataclass with slots fails. This code: from dataclasses import dataclass @dataclass(slots=True) class Base: def __post_init__(self): ...
X Description: Bug report Bug description: Using super() in __post_init__ on a dataclass with slots fails. This code: from dataclasses import dataclass @dataclass(slots=True) class Base: def __post_init__(self): ...
Opengraph URL: https://github.com/python/cpython/issues/111500
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dataclass, slots, __post_init__ and super","articleBody":"# Bug report\n\n### Bug description:\n\nUsing `super()` in `__post_init__` on a dataclass with slots fails.\n\nThis code:\n\n```python\nfrom dataclasses import dataclass\n\n@dataclass(slots=True)\nclass Base:\n def __post_init__(self):\n pass\n\n@dataclass(slots=True)\nclass Thing(Base):\n a: int\n b: int\n c: int = 0\n\n def __post_init__(self):\n self.c = self.a + self.b\n super().__post_init__()\n\nt = Thing(1,3)\n```\n\nProduces this exception:\n```\nTraceback (most recent call last):\n File \"C:\\Users\\michael.foord\\Code\\one-touch-switch-service\\example.py\", line 18, in \u003cmodule>\n t = Thing(1,3)\n ^^^^^^^^^^\n File \"\u003cstring>\", line 6, in __init__\n File \"C:\\Users\\michael.foord\\Code\\one-touch-switch-service\\example.py\", line 16, in __post_init__\n super().__post_init__()\n ^^^^^^^\nTypeError: super(type, obj): obj must be an instance or subtype of type\n```\n\nThe fix is to use Python 2 style `super(Class, self).__post_init__()`.\n\n### CPython versions tested on:\n\n3.11\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-111538\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/voidspace","@type":"Person","name":"voidspace"},"datePublished":"2023-10-30T15:44:50Z","url":"https://github.com/python/cpython/issues/111500"}
| 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:363d761c-c7d0-9658-1549-9dc88d0fee0e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EAC8:65478:3843DB9:4AA0F83:6B020AD9 |
| html-safe-nonce | 5f4ffc3611fb48d24821c75670f8177287d64967062a56d818cfa5808d3d53b4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUM4OjY1NDc4OjM4NDNEQjk6NEFBMEY4Mzo2QjAyMEFEOSIsInZpc2l0b3JfaWQiOiI1OTgxOTMxMTg2Mzc5OTUwODA5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 19908c18f3965b00a8017901fc53a5367ad0887725e9ad0526c40e2733926aee |
| hovercard-subject-tag | issue:1968682430 |
| 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/111500/issue_layout |
| twitter:image | https://opengraph.githubassets.com/33ab6c0f2c33e03d635f03bcb2aa096da2cb970036d9f5af65a6984f7a58a26f/python/cpython/issues/111500 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/33ab6c0f2c33e03d635f03bcb2aa096da2cb970036d9f5af65a6984f7a58a26f/python/cpython/issues/111500 |
| og:image:alt | Bug report Bug description: Using super() in __post_init__ on a dataclass with slots fails. This code: from dataclasses import dataclass @dataclass(slots=True) class Base: def __post_init__(self): ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | voidspace |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width