Title: "AssertionError: Cannot find component" for local NamedTuple · Issue #7281 · python/mypy · GitHub
Open Graph Title: "AssertionError: Cannot find component" for local NamedTuple · Issue #7281 · python/mypy
X Title: "AssertionError: Cannot find component" for local NamedTuple · Issue #7281 · python/mypy
Description: I've got an obscure bug which I narrowed down to some cache issues when you have a local class inheriting from NamedTuple. Stacktrace: Traceback (most recent call last): File "/home/karlicos/.local/bin/mypy", line 10, in
Open Graph Description: I've got an obscure bug which I narrowed down to some cache issues when you have a local class inheriting from NamedTuple. Stacktrace: Traceback (most recent call last): File "/home/karlicos/.local...
X Description: I've got an obscure bug which I narrowed down to some cache issues when you have a local class inheriting from NamedTuple. Stacktrace: Traceback (most recent call last): File "/home/karlic...
Opengraph URL: https://github.com/python/mypy/issues/7281
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"AssertionError: Cannot find component\" for local NamedTuple","articleBody":"I've got an obscure bug which I narrowed down to some cache issues when you have a local class inheriting from `NamedTuple`. \r\n\r\nStacktrace:\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/karlicos/.local/bin/mypy\", line 10, in \u003cmodule>\r\n sys.exit(console_entry())\r\n File \"/home/karlicos/.local/lib/python3.7/site-packages/mypy/__main__.py\", line 8, in console_entry\r\n main(None, sys.stdout, sys.stderr)\r\n File \"mypy/main.py\", line 83, in main\r\n File \"mypy/build.py\", line 164, in build\r\n File \"mypy/build.py\", line 224, in _build\r\n File \"mypy/build.py\", line 2579, in dispatch\r\n File \"mypy/build.py\", line 2885, in process_graph\r\n File \"mypy/build.py\", line 2963, in process_fresh_modules\r\n File \"mypy/build.py\", line 1876, in fix_cross_refs\r\n File \"mypy/fixup.py\", line 25, in fixup_module\r\n File \"mypy/fixup.py\", line 76, in visit_symbol_table\r\n File \"mypy/fixup.py\", line 265, in lookup_qualified_stnode\r\n File \"mypy/lookup.py\", line 47, in lookup_fully_qualified\r\nAssertionError: Cannot find component 'NT@3' for 'breaking.NT@3\r\n```\r\n\r\nEasiest to reproduce with the following script (it's crashing on the last mypy invocation)\r\n\r\n```\r\n#!/bin/bash -eux\r\ncd \"$(dirname \"$0\")\"\r\n\r\nrm -rf .mypy_cache\r\n\r\necho 'from typing import NamedTuple' > breaking.py\r\necho 'def test():' >> breaking.py\r\necho ' class NT(NamedTuple):' >> breaking.py\r\necho ' pass' >> breaking.py\r\n\r\necho 'import breaking' > script.py\r\nmypy script.py\r\n\r\necho '' > script.py\r\nmypy script.py\r\n\r\necho 'import breaking' > script.py\r\nmypy script.py\r\n```\r\n\r\nMost similar issue to this one I found seems to be https://github.com/python/mypy/issues/2931, but using singleline `NamedTuple` definition (e.g. `NT = NamedTuple('NT', [])`) doesn't result in failure, so I figured this is worth separate issue.\r\nUsing `@dataclass` doesn't result in failure either.\r\n\r\nI'm using mypy `0.720`. (upd: still happens on `0.800`)\r\n","author":{"url":"https://github.com/karlicoss","@type":"Person","name":"karlicoss"},"datePublished":"2019-08-02T15:34:41Z","url":"https://github.com/python/mypy/issues/7281"}
| 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:3e55ce6b-fb75-09c6-96df-8dc6acfd9382 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B266:142FA7:44B662:5C7E3D:6B002C52 |
| html-safe-nonce | 3075db054fb6b8330ff01d293bf19450f21dbc74727134baa721de880c0a736f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjY2OjE0MkZBNzo0NEI2NjI6NUM3RTNEOjZCMDAyQzUyIiwidmlzaXRvcl9pZCI6IjEyNDI1NDk1NzExMjk3MTU3OTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3864054689ab9278a9d6647fa24d060d81c2277762a8d563f5d9fe72c8a384fb |
| hovercard-subject-tag | issue:476239511 |
| 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/7281/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5967f261ae157c1997f31e290d6e46b4f3b5085aebe19f6e8d603b408078ffd7/python/mypy/issues/7281 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5967f261ae157c1997f31e290d6e46b4f3b5085aebe19f6e8d603b408078ffd7/python/mypy/issues/7281 |
| og:image:alt | I've got an obscure bug which I narrowed down to some cache issues when you have a local class inheriting from NamedTuple. Stacktrace: Traceback (most recent call last): File "/home/karlicos/.local... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | karlicoss |
| 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