Title: Crash when attempting a generic NamedTuple · Issue #1682 · python/mypy · GitHub
Open Graph Title: Crash when attempting a generic NamedTuple · Issue #1682 · python/mypy
X Title: Crash when attempting a generic NamedTuple · Issue #1682 · python/mypy
Description: This program causes mypy to crash: from typing import TypeVar, NamedTuple, Generic T = TypeVar('T') class C(NamedTuple('C', [('x', T),]), Generic[T]): def get(self): # type: () -> T pass Traceback (most recent call last): File "/home/gre...
Open Graph Description: This program causes mypy to crash: from typing import TypeVar, NamedTuple, Generic T = TypeVar('T') class C(NamedTuple('C', [('x', T),]), Generic[T]): def get(self): # type: () -> T pass Traceback ...
X Description: This program causes mypy to crash: from typing import TypeVar, NamedTuple, Generic T = TypeVar('T') class C(NamedTuple('C', [('x', T),]), Generic[T]): def get(self): # type:...
Opengraph URL: https://github.com/python/mypy/issues/1682
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash when attempting a generic NamedTuple","articleBody":"This program causes mypy to crash:\n\n```\nfrom typing import TypeVar, NamedTuple, Generic\n\nT = TypeVar('T')\n\nclass C(NamedTuple('C', [('x', T),]), Generic[T]):\n def get(self):\n # type: () -> T\n pass\n```\n\n```\nTraceback (most recent call last):\n File \"/home/gregprice/w/mypy/env/bin/mypy\", line 12, in \u003cmodule>\n exec(compile(open(__file__).read(), __file__, 'exec'))\n File \"/home/gregprice/w/mypy/scripts/mypy\", line 6, in \u003cmodule>\n main(__file__)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/main.py\", line 54, in main\n res = type_check_only(sources, bin_dir, options)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/main.py\", line 102, in type_check_only\n python_path=options.python_path)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/build.py\", line 211, in build\n dispatch(sources, manager)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/build.py\", line 1336, in dispatch\n process_graph(graph, manager)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/build.py\", line 1467, in process_graph\n process_stale_scc(graph, scc)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/build.py\", line 1493, in process_stale_scc\n graph[id].semantic_analysis()\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/build.py\", line 1303, in semantic_analysis\n self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 247, in visit_file\n self.accept(d)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 2283, in accept\n node.accept(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/nodes.py\", line 650, in accept\n return visitor.visit_class_def(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 567, in visit_class_def\n defn.defs.accept(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/nodes.py\", line 715, in accept\n return visitor.visit_block(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 1018, in visit_block\n self.accept(s)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 2283, in accept\n node.accept(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/nodes.py\", line 462, in accept\n return visitor.visit_func_def(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 322, in visit_func_def\n self.analyze_function(defn)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 474, in analyze_function\n defn.type = self.anal_type(defn.type)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/semanal.py\", line 1043, in anal_type\n return t.accept(a)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/types.py\", line 496, in accept\n return visitor.visit_callable_type(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/typeanal.py\", line 189, in visit_callable_type\n return t.copy_modified(arg_types=self.anal_array(t.arg_types),\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/typeanal.py\", line 259, in anal_array\n res.append(t.accept(self))\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/types.py\", line 637, in accept\n return visitor.visit_tuple_type(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/typeanal.py\", line 203, in visit_tuple_type\n return TupleType(self.anal_array(t.items), fallback, t.line)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/typeanal.py\", line 259, in anal_array\n res.append(t.accept(self))\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/types.py\", line 340, in accept\n return visitor.visit_type_var(self)\n File \"/home/gregprice/w/mypy/env/lib/python3.4/site-packages/mypy/typeanal.py\", line 186, in visit_type_var\n raise RuntimeError('TypeVarType is already analyzed')\nRuntimeError: TypeVarType is already analyzed\n\n*** INTERNAL ERROR ***\n\n/tmp/foo.py:6: error: Internal error -- please report a bug at https://github.com/python/mypy/issues\n```\n\nThis looks a lot like #685 originally did, but the repro there no longer crashes.\n\nSpotted this in https://github.com/python/typeshed/issues/236 -- this repro is a reduction of that code. The difference from the repros in #658 that no longer crash seems to be the method definition.\n","author":{"url":"https://github.com/gnprice","@type":"Person","name":"gnprice"},"datePublished":"2016-06-08T22:34:37Z","url":"https://github.com/python/mypy/issues/1682"}
| 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:742cf547-5d7d-7721-d618-04045f4662f2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 851E:3AC034:1FDE90:2B6FB9:6B00227B |
| html-safe-nonce | 6131c8b768e0d48ea4fcc66d9422bb223c0f7534c1f41de68c06a111078edb2c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTFFOjNBQzAzNDoxRkRFOTA6MkI2RkI5OjZCMDAyMjdCIiwidmlzaXRvcl9pZCI6IjU3NTkyOTM4ODE0ODUxMDc4MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8fe18cdb4ec246de8be4e676a9ec1460625189a048844fdfedb6f19a35ba69ca |
| hovercard-subject-tag | issue:159291461 |
| 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/1682/issue_layout |
| twitter:image | https://opengraph.githubassets.com/718b0a37cc284004224d1ab0d7c9b48149416d6781bdd477507b602d8960746f/python/mypy/issues/1682 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/718b0a37cc284004224d1ab0d7c9b48149416d6781bdd477507b602d8960746f/python/mypy/issues/1682 |
| og:image:alt | This program causes mypy to crash: from typing import TypeVar, NamedTuple, Generic T = TypeVar('T') class C(NamedTuple('C', [('x', T),]), Generic[T]): def get(self): # type: () -> T pass Traceback ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gnprice |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width