Title: Incorrect __post_init__ order when KW_ONLY used · Issue #17564 · python/mypy · GitHub
Open Graph Title: Incorrect __post_init__ order when KW_ONLY used · Issue #17564 · python/mypy
X Title: Incorrect __post_init__ order when KW_ONLY used · Issue #17564 · python/mypy
Description: from dataclasses import dataclass, InitVar, KW_ONLY @dataclass class A: _: KW_ONLY x: InitVar[int] def __post_init__(self, x: int) -> None: pass @dataclass class C(A): y: InitVar[str] def __post_init__(self, x: int, y: str) -> None: # Co...
Open Graph Description: from dataclasses import dataclass, InitVar, KW_ONLY @dataclass class A: _: KW_ONLY x: InitVar[int] def __post_init__(self, x: int) -> None: pass @dataclass class C(A): y: InitVar[str] def __post_in...
X Description: from dataclasses import dataclass, InitVar, KW_ONLY @dataclass class A: _: KW_ONLY x: InitVar[int] def __post_init__(self, x: int) -> None: pass @dataclass class C(A): y: InitVar[str] def __post...
Opengraph URL: https://github.com/python/mypy/issues/17564
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect __post_init__ order when KW_ONLY used","articleBody":"```python\r\nfrom dataclasses import dataclass, InitVar, KW_ONLY\r\n\r\n\r\n@dataclass\r\nclass A:\r\n _: KW_ONLY\r\n x: InitVar[int]\r\n\r\n def __post_init__(self, x: int) -> None:\r\n pass\r\n\r\n\r\n@dataclass\r\nclass C(A):\r\n y: InitVar[str]\r\n\r\n def __post_init__(self, x: int, y: str) -> None: # Correct order.\r\n super().__post_init__(x)\r\n```\r\ngives\r\n```\r\na.py:19: error: Argument 2 of \"__post_init__\" is incompatible with supertype \"dataclass\"; supertype defines the argument type as \"str\" [override]\r\n def __post_init__(self, x: int, y: str) -> None:\r\n ^~~~~~\r\na.py:19: error: Argument 3 of \"__post_init__\" is incompatible with supertype \"dataclass\"; supertype defines the argument type as \"int\" [override]\r\n def __post_init__(self, x: int, y: str) -> None:\r\n```","author":{"url":"https://github.com/NeilGirdhar","@type":"Person","name":"NeilGirdhar"},"datePublished":"2024-07-22T22:56:59Z","url":"https://github.com/python/mypy/issues/17564"}
| 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:3ab96545-aef7-b851-45ad-005e1a924f7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9504:390AA2:2A56BFD:39DA29E:6B00507C |
| html-safe-nonce | 16605056174bada8af6b29e2bc31186271d48bdfdce76c5f03bb0f79d4f9419e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTA0OjM5MEFBMjoyQTU2QkZEOjM5REEyOUU6NkIwMDUwN0MiLCJ2aXNpdG9yX2lkIjoiNDQ1ODM0MjI0NDUwNzczNDE0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ddc2b673ae39b57ff297951cd8805941f3bda34deab5c4bc66e534204133f95a |
| hovercard-subject-tag | issue:2423900581 |
| 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/mypy/17564/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42fb3cb2389e5a2bea7aabbfce08a2145765f8b9384d5b6a437104f9a7d6deb3/python/mypy/issues/17564 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42fb3cb2389e5a2bea7aabbfce08a2145765f8b9384d5b6a437104f9a7d6deb3/python/mypy/issues/17564 |
| og:image:alt | from dataclasses import dataclass, InitVar, KW_ONLY @dataclass class A: _: KW_ONLY x: InitVar[int] def __post_init__(self, x: int) -> None: pass @dataclass class C(A): y: InitVar[str] def __post_in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NeilGirdhar |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width