Title: Crash on namedtuples with attribute named `count` · Issue #3759 · python/mypy · GitHub
Open Graph Title: Crash on namedtuples with attribute named `count` · Issue #3759 · python/mypy
X Title: Crash on namedtuples with attribute named `count` · Issue #3759 · python/mypy
Description: Repro (mypy 0.520): from typing import NamedTuple class Crash(NamedTuple): count: int No crash if you rename the attribute, or stop subclassing NamedTuple. Output: test.py:4: error: INTERNAL ERROR -- please report a bug at https://github...
Open Graph Description: Repro (mypy 0.520): from typing import NamedTuple class Crash(NamedTuple): count: int No crash if you rename the attribute, or stop subclassing NamedTuple. Output: test.py:4: error: INTERNAL ERROR ...
X Description: Repro (mypy 0.520): from typing import NamedTuple class Crash(NamedTuple): count: int No crash if you rename the attribute, or stop subclassing NamedTuple. Output: test.py:4: error: INTERNAL ERROR ...
Opengraph URL: https://github.com/python/mypy/issues/3759
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash on namedtuples with attribute named `count`","articleBody":"Repro (mypy 0.520):\r\n\r\n```python\r\nfrom typing import NamedTuple\r\n\r\nclass Crash(NamedTuple):\r\n count: int\r\n```\r\n\r\nNo crash if you rename the attribute, or stop subclassing NamedTuple.\r\n\r\nOutput:\r\n```\r\ntest.py:4: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.520\r\nTraceback (most recent call last):\r\n File \"\u003c...>/venv/bin/mypy\", line 11, in \u003cmodule>\r\n sys.exit(console_entry())\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/__main__.py\", line 7, in console_entry\r\n main(None)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/main.py\", line 50, in main\r\n res = type_check_only(sources, bin_dir, options)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/main.py\", line 97, in type_check_only\r\n options=options)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/build.py\", line 196, in build\r\n graph = dispatch(sources, manager)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/build.py\", line 1769, in dispatch\r\n process_graph(graph, manager)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/build.py\", line 2012, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/build.py\", line 2115, in process_stale_scc\r\n graph[id].type_check_first_pass()\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/build.py\", line 1684, in type_check_first_pass\r\n self.type_checker.check_first_pass()\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 185, in check_first_pass\r\n self.accept(d)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 273, in accept\r\n stmt.accept(self)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/nodes.py\", line 754, in accept\r\n return visitor.visit_class_def(self)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 1109, in visit_class_def\r\n self.accept(defn.defs)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 273, in accept\r\n stmt.accept(self)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/nodes.py\", line 815, in accept\r\n return visitor.visit_block(self)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 1202, in visit_block\r\n self.accept(s)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 273, in accept\r\n stmt.accept(self)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/nodes.py\", line 859, in accept\r\n return visitor.visit_assignment_stmt(self)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 1209, in visit_assignment_stmt\r\n self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 1241, in check_assignment\r\n if self.check_compatibility_all_supers(lvalue, lvalue_type, rvalue):\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 1331, in check_compatibility_all_supers\r\n base_type, base_node = self.lvalue_type_from_base(lvalue_node, base)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/checker.py\", line 1418, in lvalue_type_from_base\r\n itype = map_instance_to_supertype(instance, base)\r\n File \"\u003c...>/venv/lib/python3.6/site-packages/mypy/maptype.py\", line 15, in map_instance_to_supertype\r\n if instance.type == superclass:\r\nAttributeError: 'TupleType' object has no attribute 'type'\r\n```","author":{"url":"https://github.com/benkuhn","@type":"Person","name":"benkuhn"},"datePublished":"2017-07-24T09:42:03Z","url":"https://github.com/python/mypy/issues/3759"}
| 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:48340021-a13a-6d16-1d76-857e4b428052 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B7DC:2148FB:2847EC1:36E9FBA:6B004745 |
| html-safe-nonce | 4a744647283d373b46f0ab5b846d589d81d4cab59bf29907102b68bb7b39358e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0RDOjIxNDhGQjoyODQ3RUMxOjM2RTlGQkE6NkIwMDQ3NDUiLCJ2aXNpdG9yX2lkIjoiMzUxNzk3MTI3MTE1MTI3Mzc5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a59dcfd8d4d5a66b4a3c962d6d6bcb409e1f218d51852053be5ef6983f3e706b |
| hovercard-subject-tag | issue:245024945 |
| 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/3759/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6ff47c5ba65faa9c2c2a5720995ae1013267aea27d46d9ed3d76297fd537558b/python/mypy/issues/3759 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6ff47c5ba65faa9c2c2a5720995ae1013267aea27d46d9ed3d76297fd537558b/python/mypy/issues/3759 |
| og:image:alt | Repro (mypy 0.520): from typing import NamedTuple class Crash(NamedTuple): count: int No crash if you rename the attribute, or stop subclassing NamedTuple. Output: test.py:4: error: INTERNAL ERROR ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | benkuhn |
| 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