Title: `tuple[*Ts]` subtype with extra type parameter not gradually assignable to itself · Issue #19908 · python/mypy · GitHub
Open Graph Title: `tuple[*Ts]` subtype with extra type parameter not gradually assignable to itself · Issue #19908 · python/mypy
X Title: `tuple[*Ts]` subtype with extra type parameter not gradually assignable to itself · Issue #19908 · python/mypy
Description: This demonstrates the issue: from typing import Any class Array[DataT, *ShapeTs](tuple[*ShapeTs]): ... type Float2D = Array[float, *tuple[int, int]] # or Array[float, int, int] type FloatND = Array[float, *tuple[Any, ...]] def from_2d(a:...
Open Graph Description: This demonstrates the issue: from typing import Any class Array[DataT, *ShapeTs](tuple[*ShapeTs]): ... type Float2D = Array[float, *tuple[int, int]] # or Array[float, int, int] type FloatND = Array...
X Description: This demonstrates the issue: from typing import Any class Array[DataT, *ShapeTs](tuple[*ShapeTs]): ... type Float2D = Array[float, *tuple[int, int]] # or Array[float, int, int] type FloatND = Array...
Opengraph URL: https://github.com/python/mypy/issues/19908
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`tuple[*Ts]` subtype with extra type parameter not gradually assignable to itself","articleBody":"This demonstrates the issue:\n\n```py\nfrom typing import Any\n\nclass Array[DataT, *ShapeTs](tuple[*ShapeTs]): ...\n\ntype Float2D = Array[float, *tuple[int, int]] # or Array[float, int, int]\ntype FloatND = Array[float, *tuple[Any, ...]]\n\ndef from_2d(a: Float2D) -> FloatND:\n return a # mypy: ✅, pyright: ✅\n\ndef into_2d(a: FloatND) -> Float2D:\n return a # mypy: ❌, pyright: ✅\n```\n\nhttps://mypy-play.net/?mypy=latest&python=3.13&flags=strict&gist=1b95c702df6de35fa3f61aa7b5dfef16\n\n\u003cdetails>\u003csummary>\nWithout the additional \u003ccode>DataT\u003c/code> typar, the false positive disappears\u003c/summary>\n\u003cp>\n\n```py\nfrom typing import Any\n\nclass Array[*ShapeTs](tuple[*ShapeTs]): ...\n\ntype Float2D = Array[*tuple[int, int]] # or Array[int, int]\ntype FloatND = Array[*tuple[Any, ...]]\n\ndef from_2d(a: Float2D) -> FloatND:\n return a # mypy: ✅, pyright: ✅\n\ndef into_2d(a: FloatND) -> Float2D:\n return a # mypy: ✅, pyright: ✅\n```\n\nhttps://mypy-play.net/?mypy=latest&python=3.13&flags=strict&gist=be0dfedeb0e7ed14da359cd52d2901e7\n\n\u003c/p>\n\u003c/details> \n\n\n\u003cdetails>\u003csummary>\nThe issue also disappears when tuple is no longer a base class\u003c/summary>\n\u003cp>\n\n```py\nfrom typing import Any\n\nclass Array[float, *ShapeTs]: ...\n\ntype Float2D = Array[float, *tuple[int, int]] # or Array[float, int, int]\ntype FloatND = Array[float, *tuple[Any, ...]]\n\ndef from_2d(a: Float2D) -> FloatND:\n return a # mypy: ✅, pyright: ✅\n\ndef into_2d(a: FloatND) -> Float2D:\n return a # mypy: ✅, pyright: ✅\n```\n\nhttps://mypy-play.net/?mypy=latest&python=3.13&flags=strict&gist=a1439e7c3037239bc4663b981534fb17\n\n\u003c/p>\n\u003c/details> \n\n\nPotentially related issues:\n- #18665\n- #19106\n- #19109\n- #19110\n- #19860 \n- #19858","author":{"url":"https://github.com/jorenham","@type":"Person","name":"jorenham"},"datePublished":"2025-09-23T14:33:13Z","url":"https://github.com/python/mypy/issues/19908"}
| 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:0130ac16-25b7-6bf0-daaf-b5ed913278e7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA68:7F150:1BD7A37:24E420E:6B002EFB |
| html-safe-nonce | 17dafadf68af94c4d895559b9f8be77483140b1cb0e2403c2744897983fe2635 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTY4OjdGMTUwOjFCRDdBMzc6MjRFNDIwRTo2QjAwMkVGQiIsInZpc2l0b3JfaWQiOiIxODAyNjk3MjczMTM4NzUzMjc1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | df2e66eba7177baf5635e47211739e8132484c65a9016508c40cbee117d795cf |
| hovercard-subject-tag | issue:3445551233 |
| 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/19908/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa9a810bc9aa6afd84eb6e8265909af4e3ae2f34ead85c6bf6300f39102ab6ee/python/mypy/issues/19908 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa9a810bc9aa6afd84eb6e8265909af4e3ae2f34ead85c6bf6300f39102ab6ee/python/mypy/issues/19908 |
| og:image:alt | This demonstrates the issue: from typing import Any class Array[DataT, *ShapeTs](tuple[*ShapeTs]): ... type Float2D = Array[float, *tuple[int, int]] # or Array[float, int, int] type FloatND = Array... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jorenham |
| 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