Title: Append Any to unparametrized generics in upper bounds of type variables · Issue #3153 · python/mypy · GitHub
Open Graph Title: Append Any to unparametrized generics in upper bounds of type variables · Issue #3153 · python/mypy
X Title: Append Any to unparametrized generics in upper bounds of type variables · Issue #3153 · python/mypy
Description: T = TypeVar('T') class X(Generic[T]): v: T U = TypeVar('U', bound=X) def f(x: U, v: T) -> None: x.v = v # Incompatible types in assignment (expression has type "T", variable has type "T") The fact that the error is reported is perfectly ...
Open Graph Description: T = TypeVar('T') class X(Generic[T]): v: T U = TypeVar('U', bound=X) def f(x: U, v: T) -> None: x.v = v # Incompatible types in assignment (expression has type "T", variable has type "T") The fact ...
X Description: T = TypeVar('T') class X(Generic[T]): v: T U = TypeVar('U', bound=X) def f(x: U, v: T) -> None: x.v = v # Incompatible types in assignment (expression has type "T", var...
Opengraph URL: https://github.com/python/mypy/issues/3153
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Append Any to unparametrized generics in upper bounds of type variables","articleBody":"```\r\nT = TypeVar('T')\r\n\r\nclass X(Generic[T]):\r\n v: T\r\n\r\nU = TypeVar('U', bound=X)\r\n\r\ndef f(x: U, v: T) -> None:\r\n x.v = v # Incompatible types in assignment (expression has type \"T\", variable has type \"T\")\r\n```\r\n\r\nThe fact that the error is reported is perfectly fine, but the error message is a mini-puzzle 😆 \r\n\r\nI don't have an opinion about the best message, but one option is to reuse the notation followed by `reveal_type`:\r\n\r\n```\r\n reveal_type(x.v) # Revealed type is 'T`1'\r\n reveal_type(v) # Revealed type is 'T`-2'\r\n```\r\n\r\nWhile somewhat cryptic, it already appears in `reveal_type` messages anyway, so it might be worth adding the explanation of this notation to the docs. Of course, the user won't know the internal type ids, so he still won't know what ``T`1`` and ``T`-2`` correspond to exactly, but this will at least send him on the right path.","author":{"url":"https://github.com/pkch","@type":"Person","name":"pkch"},"datePublished":"2017-04-10T21:14:58Z","url":"https://github.com/python/mypy/issues/3153"}
| 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:0e66d4e0-3a5b-9d8e-07f5-d88bc59c52fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84A6:1EFC64:504630:70849F:6B007404 |
| html-safe-nonce | ce6193c71f1bd35c970f7d90bbbb8b4417631ded90cd2666751a5c8461bcec01 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEE2OjFFRkM2NDo1MDQ2MzA6NzA4NDlGOjZCMDA3NDA0IiwidmlzaXRvcl9pZCI6IjkxNzEyMzI1MzU4MzU4NjYxMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c81e9d3ca855aeb7afeec15fa12edffa33ddf75304f2543e4c02f25682e09d3c |
| hovercard-subject-tag | issue:220772809 |
| 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/3153/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f29c8fcfb452b27e04d1c6a071d696a6b6e928de0ac18e139de9916e288034a/python/mypy/issues/3153 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f29c8fcfb452b27e04d1c6a071d696a6b6e928de0ac18e139de9916e288034a/python/mypy/issues/3153 |
| og:image:alt | T = TypeVar('T') class X(Generic[T]): v: T U = TypeVar('U', bound=X) def f(x: U, v: T) -> None: x.v = v # Incompatible types in assignment (expression has type "T", variable has type "T") The fact ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pkch |
| hostname | github.com |
| expected-hostname | github.com |
| None | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| 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 | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width