Title: Invalid type revealed when type var uses another type var as default · Issue #20027 · python/mypy · GitHub
Open Graph Title: Invalid type revealed when type var uses another type var as default · Issue #20027 · python/mypy
X Title: Invalid type revealed when type var uses another type var as default · Issue #20027 · python/mypy
Description: from typing import TypeVar, Generic X = TypeVar('X') Y = TypeVar('Y', default=X) Z = TypeVar('Z', default=Y) class A(Generic[X, Y, Z]): x: X y: Y z: Z a1: A[int] reveal_type(a1.x) # N: Revealed type is "builtins.int" reveal_type(a1.y) # ...
Open Graph Description: from typing import TypeVar, Generic X = TypeVar('X') Y = TypeVar('Y', default=X) Z = TypeVar('Z', default=Y) class A(Generic[X, Y, Z]): x: X y: Y z: Z a1: A[int] reveal_type(a1.x) # N: Revealed typ...
X Description: from typing import TypeVar, Generic X = TypeVar('X') Y = TypeVar('Y', default=X) Z = TypeVar('Z', default=Y) class A(Generic[X, Y, Z]): x: X y: Y z: Z a1: A[int] reveal_type...
Opengraph URL: https://github.com/python/mypy/issues/20027
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invalid type revealed when type var uses another type var as default","articleBody":"```python\nfrom typing import TypeVar, Generic\n\nX = TypeVar('X')\nY = TypeVar('Y', default=X)\nZ = TypeVar('Z', default=Y)\n\nclass A(Generic[X, Y, Z]):\n x: X\n y: Y\n z: Z\n\na1: A[int]\nreveal_type(a1.x) # N: Revealed type is \"builtins.int\"\nreveal_type(a1.y) # N: Revealed type is \"builtins.int\"\nreveal_type(a1.z) # N: Revealed type is \"X`1\"\n```\n\n`a1.z` must be revealed as `int` as well, not as `X'1`\n\nRefs https://github.com/python/mypy/pull/20021","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2025-10-08T07:27:38Z","url":"https://github.com/python/mypy/issues/20027"}
| 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:1d96afd3-cac2-2262-e38c-e873873f1b3d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C52:1E3154:3D52F7:528E10:6B002A20 |
| html-safe-nonce | 165a41a90e8108676e8be32c2313741aed2c138067f4b55b540c07a4d46c9241 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzUyOjFFMzE1NDozRDUyRjc6NTI4RTEwOjZCMDAyQTIwIiwidmlzaXRvcl9pZCI6IjEzMDgxNjYyMzQ2NDIwNjU5NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b1cbc7b5d177854626a1bc405bfeffaf10dba5d119e00e0d9e17bd023cad25e0 |
| hovercard-subject-tag | issue:3494215474 |
| 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/20027/issue_layout |
| twitter:image | https://opengraph.githubassets.com/79d66308e3bdba3ed3db8f52166d36e22ccd4bb38a85627c29d9bdb6e721039c/python/mypy/issues/20027 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/79d66308e3bdba3ed3db8f52166d36e22ccd4bb38a85627c29d9bdb6e721039c/python/mypy/issues/20027 |
| og:image:alt | from typing import TypeVar, Generic X = TypeVar('X') Y = TypeVar('Y', default=X) Z = TypeVar('Z', default=Y) class A(Generic[X, Y, Z]): x: X y: Y z: Z a1: A[int] reveal_type(a1.x) # N: Revealed typ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| 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