René's URL Explorer Experiment


Title: Crash when class defined in method used for instance variable's type · Issue #2559 · python/mypy · GitHub

Open Graph Title: Crash when class defined in method used for instance variable's type · Issue #2559 · python/mypy

X Title: Crash when class defined in method used for instance variable's type · Issue #2559 · python/mypy

Description: While thinking about #2535 I realized there's a similar case not involving NamedTuple (nor TypedDict): main.py: import crash blah # anything that triggers an error crash.py: class C: def f(self) -> None: class A: pass self.a = A() This t...

Open Graph Description: While thinking about #2535 I realized there's a similar case not involving NamedTuple (nor TypedDict): main.py: import crash blah # anything that triggers an error crash.py: class C: def f(self) ->...

X Description: While thinking about #2535 I realized there's a similar case not involving NamedTuple (nor TypedDict): main.py: import crash blah # anything that triggers an error crash.py: class C: def f(self...

Opengraph URL: https://github.com/python/mypy/issues/2559

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash when class defined in method used for instance variable's type","articleBody":"While thinking about https://github.com/python/mypy/issues/2535 I realized there's a similar case not involving NamedTuple (nor TypedDict):\r\n\r\n- main.py:\r\n```python\r\nimport crash\r\nblah  # anything that triggers an error\r\n```\r\n\r\n- crash.py:\r\n```python\r\nclass C:\r\n    def f(self) -> None:\r\n        class A:\r\n            pass\r\n        self.a = A()\r\n```\r\nThis triggers a very similar crash in fixup.py when running `mypy -i main.py` **TWICE** (from a cold cache):\r\n```\r\n$ rm -rf .mypy_cache/\r\n$ mypy -i main.py \r\nmain.py:1: error: Name 'blah' is not defined\r\n$ mypy -i main.py \r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.6/runpy.py\", line 193, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/local/lib/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/Users/guido/src/mypy/mypy/__main__.py\", line 5, in \u003cmodule>\r\n    main(None)\r\n  File \"/Users/guido/src/mypy/mypy/main.py\", line 41, in main\r\n    res = type_check_only(sources, bin_dir, options)\r\n  File \"/Users/guido/src/mypy/mypy/main.py\", line 86, in type_check_only\r\n    options=options)\r\n  File \"/Users/guido/src/mypy/mypy/build.py\", line 183, in build\r\n    dispatch(sources, manager)\r\n  File \"/Users/guido/src/mypy/mypy/build.py\", line 1524, in dispatch\r\n    process_graph(graph, manager)\r\n  File \"/Users/guido/src/mypy/mypy/build.py\", line 1753, in process_graph\r\n    process_fresh_scc(graph, prev_scc)\r\n  File \"/Users/guido/src/mypy/mypy/build.py\", line 1822, in process_fresh_scc\r\n    graph[id].fix_cross_refs()\r\n  File \"/Users/guido/src/mypy/mypy/build.py\", line 1307, in fix_cross_refs\r\n    fixup_module_pass_one(self.tree, self.manager.modules)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 21, in fixup_module_pass_one\r\n    node_fixer.visit_symbol_table(tree.names)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 86, in visit_symbol_table\r\n    self.visit_type_info(value.node)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 55, in visit_type_info\r\n    self.visit_symbol_table(info.names)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 88, in visit_symbol_table\r\n    value.node.accept(self)\r\n  File \"/Users/guido/src/mypy/mypy/nodes.py\", line 658, in accept\r\n    return visitor.visit_var(self)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 131, in visit_var\r\n    v.type.accept(self.type_fixer)\r\n  File \"/Users/guido/src/mypy/mypy/types.py\", line 433, in accept\r\n    return visitor.visit_instance(self)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 144, in visit_instance\r\n    node = lookup_qualified(self.modules, type_ref)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 234, in lookup_qualified\r\n    stnode = lookup_qualified_stnode(modules, name)\r\n  File \"/Users/guido/src/mypy/mypy/fixup.py\", line 245, in lookup_qualified_stnode\r\n    assert '.' in head, \"Cannot find %s\" % (name,)\r\nAssertionError: Cannot find A\r\n```","author":{"url":"https://github.com/gvanrossum","@type":"Person","name":"gvanrossum"},"datePublished":"2016-12-12T22:15:43Z","url":"https://github.com/python/mypy/issues/2559"}

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:66aed9cd-2dee-d9c5-daa1-6158646b7443
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id94DC:2AB36C:2B2E00:3AC548:6B006A00
html-safe-nonce9d397b7f916c82a6ace74b2b4b318338c061cb7aea2ba66beca0541f0363eb66
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NERDOjJBQjM2QzoyQjJFMDA6M0FDNTQ4OjZCMDA2QTAwIiwidmlzaXRvcl9pZCI6Ijc1MzY2NzAzMzYzNDM4OTQ1MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfcf468c1296be2a9086f9d9846ce6ecaf4c7981a1deb8844cc400d0e444d2dbf
hovercard-subject-tagissue:195101374
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/2559/issue_layout
twitter:imagehttps://opengraph.githubassets.com/985df8bed63c10f1026e5bc499826925fd0b3844a40fb4623c2f6a1c01861d26/python/mypy/issues/2559
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/985df8bed63c10f1026e5bc499826925fd0b3844a40fb4623c2f6a1c01861d26/python/mypy/issues/2559
og:image:altWhile thinking about #2535 I realized there's a similar case not involving NamedTuple (nor TypedDict): main.py: import crash blah # anything that triggers an error crash.py: class C: def f(self) ->...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegvanrossum
hostnamegithub.com
expected-hostnamegithub.com
None6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa
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
release46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/2559#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F2559
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%2F2559
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/2559
Reloadhttps://github.com/python/mypy/issues/2559
Reloadhttps://github.com/python/mypy/issues/2559
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 requests543 (543)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/2559
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/2559
Crash when class defined in method used for instance variable's typehttps://github.com/python/mypy/issues/2559#top
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
topic-incrementalhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-incremental%22
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Dec 12, 2016https://github.com/python/mypy/issues/2559#issue-195101374
#2535https://github.com/python/mypy/issues/2535
gvanrossumhttps://github.com/gvanrossum
topic-incrementalhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-incremental%22
on Jan 14, 2017https://github.com/python/mypy/issues/2559#event-923025441
JukkaLhttps://github.com/JukkaL
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
on Jan 16, 2017https://github.com/python/mypy/issues/2559#event-924285888
JukkaLhttps://github.com/JukkaL
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2855https://github.com/python/mypy/pull/2855
on Feb 27, 2017https://github.com/python/mypy/issues/2559#event-978699968
JukkaLhttps://github.com/JukkaL
on Feb 27, 2017https://github.com/python/mypy/issues/2559#event-978700065
Fix crash on access to local classes (#2855)https://github.com/python/mypy/commit/ef6f156f43c325ca904b925b18d987788fc46388
#2855https://github.com/python/mypy/pull/2855
https://docs.github.com/articles/closing-issues-via-commit-messages
ef6f156https://github.com/python/mypy/commit/ef6f156f43c325ca904b925b18d987788fc46388
ilevkivskyihttps://github.com/ilevkivskyi
on Mar 7, 2017https://github.com/python/mypy/issues/2559#event-990537830
Remove assertions from lookup code in fixup.py, replace with soft fai…https://github.com/python/mypy/commit/b51ae241ffa9da607dc4a1dabe9d799c507da0fb
b51ae24https://github.com/python/mypy/commit/b51ae241ffa9da607dc4a1dabe9d799c507da0fb
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/2559
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/2559
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
crashhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22crash%22
priority-0-highhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22priority-0-high%22
topic-incrementalhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-incremental%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.