René's URL Explorer Experiment


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

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@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-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:01a4d48c-05a7-5647-7087-df0fe847232f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA1AA:1DD784:E8CF0C:13887B3:6B0057F1
html-safe-nonce0648a2d1dc9d97b96adf2b320d237e26c2073c88ba98684580ffda69ab8a4d0c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUFBOjFERDc4NDpFOENGMEM6MTM4ODdCMzo2QjAwNTdGMSIsInZpc2l0b3JfaWQiOiI5MDYzNDA1MzMzMTcwMzc4NzM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaccb5e6d845d63568083d1436c73f3f92f97d5004934a407da20e5efebd2cd3cac
hovercard-subject-tagissue:129268674
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/1174/issue_layout
twitter:imagehttps://opengraph.githubassets.com/89ef7f6ba406c45c739a645d201fac28eb87be1a3fd3b3ed76bc8e4bab162b15/python/mypy/issues/1174
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/89ef7f6ba406c45c739a645d201fac28eb87be1a3fd3b3ed76bc8e4bab162b15/python/mypy/issues/1174
og:image:altfrom 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:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametimabbott
hostnamegithub.com
expected-hostnamegithub.com
Nonef420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release26e00df917aba0f128135dc073ea0c5e33a70d40
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/1174#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F1174
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F1174
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/1174
Reloadhttps://github.com/python/mypy/issues/1174
Reloadhttps://github.com/python/mypy/issues/1174
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests546 (546)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/1174
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/1174
Mypy errors with variable reuse with different typeshttps://github.com/python/mypy/issues/1174#top
https://github.com/JukkaL
false-positivemypy gave an error on correct codehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22false-positive%22
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
topic-usabilityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-usability%22
https://github.com/timabbott
timabbotthttps://github.com/timabbott
on Jan 27, 2016https://github.com/python/mypy/issues/1174#issue-129268674
Nexthttps://github.com/python/mypy/issues/1174?timeline_page=1
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jan 27, 2016https://github.com/python/mypy/issues/1174#issuecomment-175854832
JukkaLhttps://github.com/JukkaL
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
on Feb 4, 2016https://github.com/python/mypy/issues/1174#event-539372890
JukkaLhttps://github.com/JukkaL
on Feb 4, 2016https://github.com/python/mypy/issues/1174#event-539373425
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Feb 4, 2016https://github.com/python/mypy/issues/1174#issuecomment-179920586
ddfisherhttps://github.com/ddfisher
on Mar 1, 2016https://github.com/python/mypy/issues/1174#event-573894771
https://github.com/matthiaskramm
matthiaskrammhttps://github.com/matthiaskramm
on Apr 13, 2016https://github.com/python/mypy/issues/1174#issuecomment-209465957
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Apr 14, 2016https://github.com/python/mypy/issues/1174#issuecomment-210122351
https://github.com/ddfisher
ddfisherhttps://github.com/ddfisher
on Apr 14, 2016https://github.com/python/mypy/issues/1174#issuecomment-210126652
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Apr 14, 2016https://github.com/python/mypy/issues/1174#issuecomment-210129897
#1174 (comment)https://github.com/python/mypy/issues/1174#issuecomment-210126652
https://github.com/timabbott
timabbotthttps://github.com/timabbott
on Apr 14, 2016https://github.com/python/mypy/issues/1174#issuecomment-210132347
https://github.com/ddfisher
ddfisherhttps://github.com/ddfisher
on Apr 14, 2016https://github.com/python/mypy/issues/1174#issuecomment-210135049
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Apr 14, 2016https://github.com/python/mypy/issues/1174#issuecomment-210140843
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Apr 15, 2016https://github.com/python/mypy/issues/1174#issuecomment-210502303
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Apr 15, 2016https://github.com/python/mypy/issues/1174#issuecomment-210524281
#1094https://github.com/python/mypy/issues/1094
JukkaLhttps://github.com/JukkaL
on Apr 16, 2016https://github.com/python/mypy/issues/1174#event-629926465
https://github.com/emmatyping
emmatypinghttps://github.com/emmatyping
on Nov 14, 2020https://github.com/python/mypy/issues/1174#issuecomment-727216295
@alex4747-pubhttps://github.com/alex4747-pub
--allow-redefinitionhttps://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-allow-redefinition
https://github.com/alex4747-pub
alex4747-pubhttps://github.com/alex4747-pub
on Nov 14, 2020https://github.com/python/mypy/issues/1174#issuecomment-727216831
https://github.com/uranusjr
uranusjrhttps://github.com/uranusjr
on Dec 24, 2020https://github.com/python/mypy/issues/1174#issuecomment-750923741
https://github.com/alex4747-pub
alex4747-pubhttps://github.com/alex4747-pub
on Dec 26, 2020https://github.com/python/mypy/issues/1174#issuecomment-751311320
pavpenhttps://github.com/pavpen
on Feb 15, 2021https://github.com/python/mypy/issues/1174#event-4329632947
Use Different Temporary Variables to Satisfy MyPyhttps://github.com/pavpen/cadquery/commit/d4879652db294e1a2b6e4649e9d058ab79451cab
d487965https://github.com/pavpen/cadquery/commit/d4879652db294e1a2b6e4649e9d058ab79451cab
PIG208https://github.com/PIG208
on Jul 26, 2021https://github.com/python/mypy/issues/1174#event-5069980693
typing: Avoid scoped redefinition of different types.https://github.com/PIG208/zulip/commit/13a16fa331fd00b07814dc40806bef3fbc60ea88
13a16fahttps://github.com/PIG208/zulip/commit/13a16fa331fd00b07814dc40806bef3fbc60ea88
typing: Avoid scoped redefinition of different types.https://github.com/PIG208/zulip/commit/8330b5c7b38a13f66dc7e26318f9baf42dd01121
8330b5chttps://github.com/PIG208/zulip/commit/8330b5c7b38a13f66dc7e26318f9baf42dd01121
typing: Avoid scoped redefinition of different types.https://github.com/PIG208/zulip/commit/39f049fc29f88dc6dd475fa8cd3a13cec002bf14
39f049fhttps://github.com/PIG208/zulip/commit/39f049fc29f88dc6dd475fa8cd3a13cec002bf14
timabbotthttps://github.com/timabbott
on Jul 26, 2021https://github.com/python/mypy/issues/1174#event-5071000614
typing: Avoid scoped redefinition of different types.https://github.com/zulip/zulip/commit/91de2cbe0364148883fed29d23fe90d95508278f
91de2cbhttps://github.com/zulip/zulip/commit/91de2cbe0364148883fed29d23fe90d95508278f
shawnbrownhttps://github.com/shawnbrown
on Sep 11, 2021https://github.com/python/mypy/issues/1174#event-5287762706
Avoid reuse of variable name for values of different types.https://github.com/shawnbrown/EnvLauncher/commit/8f15b0427bc2dcf739cc286c4605537734018f3d
8f15b04https://github.com/shawnbrown/EnvLauncher/commit/8f15b0427bc2dcf739cc286c4605537734018f3d
Lai-YThttps://github.com/Lai-YT
on Jan 14, 2022https://github.com/python/mypy/issues/1174#event-5895580256
Suppress mypy error on a common themehttps://github.com/Lai-YT/webcam-applications/commit/7abd55dff72d9069b74edbe66f012f9dfccbd475
7abd55dhttps://github.com/Lai-YT/webcam-applications/commit/7abd55dff72d9069b74edbe66f012f9dfccbd475
https://github.com/tsibley
tsibleyhttps://github.com/tsibley
on Mar 9, 2022https://github.com/python/mypy/issues/1174#issuecomment-1063266478
tsibleyhttps://github.com/tsibley
on Mar 9, 2022https://github.com/python/mypy/issues/1174#event-6212451252
runner.docker: Appease mypy and avoid redefining the type of "limits"https://github.com/nextstrain/cli/commit/83d83ce622eb3dc6d95a6a81537e3dcee5081c3e
83d83cehttps://github.com/nextstrain/cli/commit/83d83ce622eb3dc6d95a6a81537e3dcee5081c3e
https://github.com/solsword
solswordhttps://github.com/solsword
on Apr 3, 2022https://github.com/python/mypy/issues/1174#issuecomment-1086840560
#2806https://github.com/python/mypy/issues/2806
#6263https://github.com/python/mypy/pull/6263
@alex4747-pubhttps://github.com/alex4747-pub
#6232 (comment)https://github.com/python/mypy/issues/6232#issuecomment-633551053
#2806 (comment)https://github.com/python/mypy/issues/2806#issuecomment-278061126
bhearsumhttps://github.com/bhearsum
on May 1, 2025https://github.com/python/mypy/issues/1174#event-17489903483
Bug 1638892 [wpt PR 23669] - Rename variable to avoid mypy type error…https://github.com/mozilla-releng/staging-firefox/commit/2cfbe9164aad2ec46748b5b2189959fffcb4ea19
2cfbe91https://github.com/mozilla-releng/staging-firefox/commit/2cfbe9164aad2ec46748b5b2189959fffcb4ea19
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/1174
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/1174
JukkaLhttps://github.com/JukkaL
false-positivemypy gave an error on correct codehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22false-positive%22
needs discussionhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22needs%20discussion%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
topic-usabilityhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-usability%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.