Title: dataclass does not properly support generics · Issue #7520 · python/mypy · GitHub
Open Graph Title: dataclass does not properly support generics · Issue #7520 · python/mypy
X Title: dataclass does not properly support generics · Issue #7520 · python/mypy
Description: Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? I believe this is a bug. Please insert below the code you are checking with mypy, or a mock-up repro if the source is...
Open Graph Description: Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? I believe this is a bug. Please insert below the code you are checking with m...
X Description: Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? I believe this is a bug. Please insert below the code you are checking with m...
Opengraph URL: https://github.com/python/mypy/issues/7520
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dataclass does not properly support generics","articleBody":"Please provide more information to help us understand the issue:\r\n\r\n* Are you reporting a bug, or opening a feature request?\r\n\r\nI believe this is a bug.\r\n\r\n* Please insert below the code you are checking with mypy,\r\n or a mock-up repro if the source is private. We would appreciate\r\n if you try to simplify your case to a minimal repro.\r\n\r\nHere is MRE:\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nfrom typing import Generic, NewType, TypeVar\r\n\r\nT = TypeVar(\"T\")\r\nV = NewType(\"V\", int)\r\n\r\n@dataclass\r\nclass Base(Generic[T]):\r\n attr: T\r\n\r\n# If this decorator is commented than the generic works as expected\r\n@dataclass\r\nclass Sub(Base[V]):\r\n pass\r\n\r\nSub(attr=V(1))\r\n```\r\n\r\n* What is the actual behavior/output?\r\n\r\n`Argument \"attr\" to \"Sub\" has incompatible type \"V\"; expected \"T\"`\r\n\r\n* What is the behavior/output you expect?\r\n\r\nThe code should type check.\r\n\r\n* What are the versions of mypy and Python you are using?\r\n Do you see the same issue after installing mypy from Git master?\r\n\r\n`mypy 0.720`\r\nyes, tested against: `8782ae7f789ad5b8cab97d3c8419f9f98b6eb285`\r\n\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\n\r\nThe defaults, executed with: `mypy test_script.py`\r\n\r\n* If mypy crashed with a traceback, please paste\r\n the full traceback below.\r\n\r\n\r\n","author":{"url":"https://github.com/hackaugusto","@type":"Person","name":"hackaugusto"},"datePublished":"2019-09-16T15:52:10Z","url":"https://github.com/python/mypy/issues/7520"}
| 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:a701b4f3-79e3-1b61-f01b-cbd7a7ae58bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF9C:34D604:19C7D47:221223E:6B002C55 |
| html-safe-nonce | 6153b82512d66a78d798fdd173971bee8e054e0d491a02be9202b37f17b3b0bb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjlDOjM0RDYwNDoxOUM3RDQ3OjIyMTIyM0U6NkIwMDJDNTUiLCJ2aXNpdG9yX2lkIjoiMzg1NDY1MDMxMjkyMDkzNTUxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 52c29dfafe8b04606405e6c68cc125800615504ad4259f25278101714a6d548a |
| hovercard-subject-tag | issue:494135453 |
| 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/7520/issue_layout |
| twitter:image | https://opengraph.githubassets.com/94023f2b645ceb971ced856b1d1082a0ab84c152a686c2fbfcf172bbc6286242/python/mypy/issues/7520 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/94023f2b645ceb971ced856b1d1082a0ab84c152a686c2fbfcf172bbc6286242/python/mypy/issues/7520 |
| og:image:alt | Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? I believe this is a bug. Please insert below the code you are checking with m... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hackaugusto |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width