Title: Mypy errors with variable reuse with different types · Issue #1174 · python/mypy · GitHub
Open Graph Title: Mypy errors with variable reuse with different types · Issue #1174 · python/mypy
X Title: Mypy errors with variable reuse with different types · Issue #1174 · python/mypy
Description: from typing import * class Test(object): x = 1 y = 2 for sub in [(1, 2)]: pass subs = {} # type: Dict[Tuple[int, int], Test] for sub in [Test()]: subs[(sub.x, sub.y)] = sub gives /home/tabbott/foo.py:11: error: Incompatible types in assi...
Open Graph Description: from typing import * class Test(object): x = 1 y = 2 for sub in [(1, 2)]: pass subs = {} # type: Dict[Tuple[int, int], Test] for sub in [Test()]: subs[(sub.x, sub.y)] = sub gives /home/tabbott/foo....
X Description: from typing import * class Test(object): x = 1 y = 2 for sub in [(1, 2)]: pass subs = {} # type: Dict[Tuple[int, int], Test] for sub in [Test()]: subs[(sub.x, sub.y)] = sub gives /home/tabbott/foo....
Mail addresses
notifications@github.com
Opengraph URL: https://github.com/python/mypy/issues/1174
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy errors with variable reuse with different types","articleBody":"```\nfrom typing import *\n\nclass Test(object):\n x = 1\n y = 2\n\nfor sub in [(1, 2)]:\n pass\n\nsubs = {} # type: Dict[Tuple[int, int], Test] \nfor sub in [Test()]:\n subs[(sub.x, sub.y)] = sub\n```\n\ngives\n\n```\n/home/tabbott/foo.py:11: error: Incompatible types in assignment (expression has type \"Test\", variable has type \"Tuple[int, int]\")\n/home/tabbott/foo.py:12: error: Tuple[int, ...] has no attribute \"x\"\n/home/tabbott/foo.py:12: error: Tuple[int, ...] has no attribute \"y\"\n/home/tabbott/foo.py:12: error: Incompatible types in assignment\n```\n\nArguably this is not perfect code, but probably this shouldn't be a mypy error?\n","author":{"url":"https://github.com/timabbott","@type":"Person","name":"timabbott"},"datePublished":"2016-01-27T21:07:54Z","url":"https://github.com/python/mypy/issues/1174"}
| 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:01a4d48c-05a7-5647-7087-df0fe847232f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A1AA:1DD784:E8CF0C:13887B3:6B0057F1 |
| html-safe-nonce | 0648a2d1dc9d97b96adf2b320d237e26c2073c88ba98684580ffda69ab8a4d0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUFBOjFERDc4NDpFOENGMEM6MTM4ODdCMzo2QjAwNTdGMSIsInZpc2l0b3JfaWQiOiI5MDYzNDA1MzMzMTcwMzc4NzM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cb5e6d845d63568083d1436c73f3f92f97d5004934a407da20e5efebd2cd3cac |
| hovercard-subject-tag | issue:129268674 |
| 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/1174/issue_layout |
| twitter:image | https://opengraph.githubassets.com/89ef7f6ba406c45c739a645d201fac28eb87be1a3fd3b3ed76bc8e4bab162b15/python/mypy/issues/1174 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/89ef7f6ba406c45c739a645d201fac28eb87be1a3fd3b3ed76bc8e4bab162b15/python/mypy/issues/1174 |
| og:image:alt | from typing import * class Test(object): x = 1 y = 2 for sub in [(1, 2)]: pass subs = {} # type: Dict[Tuple[int, int], Test] for sub in [Test()]: subs[(sub.x, sub.y)] = sub gives /home/tabbott/foo.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timabbott |
| 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