Title: Internal error when overriding frozen attribute with function · Issue #8976 · python/mypy · GitHub
Open Graph Title: Internal error when overriding frozen attribute with function · Issue #8976 · python/mypy
X Title: Internal error when overriding frozen attribute with function · Issue #8976 · python/mypy
Description: Running mypy on this from dataclasses import dataclass @dataclass(frozen=True) class Foo: attr: int @dataclass(frozen=True) class Bar(Foo): def attr(self) -> int: return 1 produces the following error foo.py:10: error: INTERNAL ERROR -- ...
Open Graph Description: Running mypy on this from dataclasses import dataclass @dataclass(frozen=True) class Foo: attr: int @dataclass(frozen=True) class Bar(Foo): def attr(self) -> int: return 1 produces the following er...
X Description: Running mypy on this from dataclasses import dataclass @dataclass(frozen=True) class Foo: attr: int @dataclass(frozen=True) class Bar(Foo): def attr(self) -> int: return 1 produces the following...
Opengraph URL: https://github.com/python/mypy/issues/8976
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Internal error when overriding frozen attribute with function","articleBody":"Running mypy on this\r\n```python\r\nfrom dataclasses import dataclass\r\n\r\n\r\n@dataclass(frozen=True)\r\nclass Foo:\r\n attr: int\r\n\r\n\r\n@dataclass(frozen=True)\r\nclass Bar(Foo):\r\n def attr(self) -> int:\r\n return 1\r\n```\r\n\r\nproduces the following error\r\n```\r\nfoo.py:10: error: INTERNAL ERROR -- Please try using mypy master on Github:\r\nhttps://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 0.790+dev.793cf187f0e529f9d6623a512ae0149124ded542\r\nTraceback (most recent call last):\r\n File \"/home/karl/tools/venv/bin/mypy\", line 8, in \u003cmodule>\r\n sys.exit(console_entry())\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/__main__.py\", line 8, in console_entry\r\n main(None, sys.stdout, sys.stderr)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/main.py\", line 89, in main\r\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/build.py\", line 181, in build\r\n sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/build.py\", line 252, in _build\r\n graph = dispatch(sources, manager, stdout)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/build.py\", line 2626, in dispatch\r\n process_graph(graph, manager)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/build.py\", line 2949, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/build.py\", line 3041, in process_stale_scc\r\n mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal_main.py\", line 78, in semantic_analysis_for_scc\r\n process_top_levels(graph, scc, patches)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal_main.py\", line 203, in process_top_levels\r\n patches)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal_main.py\", line 331, in semantic_analyze_target\r\n active_type=active_type)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 357, in refresh_partial\r\n self.refresh_top_level(node)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 368, in refresh_top_level\r\n self.accept(d)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 4691, in accept\r\n node.accept(self)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/nodes.py\", line 940, in accept\r\n return visitor.visit_class_def(self)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 1011, in visit_class_def\r\n self.analyze_class(defn)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 1088, in analyze_class\r\n self.analyze_class_body_common(defn)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 1097, in analyze_class_body_common\r\n self.apply_class_plugin_hooks(defn)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/semanal.py\", line 1143, in apply_class_plugin_hooks\r\n hook(ClassDefContext(defn, decorator, self))\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/plugins/dataclasses.py\", line 348, in dataclass_class_maker_callback\r\n transformer.transform()\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/plugins/dataclasses.py\", line 161, in transform\r\n self._freeze(attributes)\r\n File \"/home/karl/tools/venv/lib/python3.7/site-packages/mypy/plugins/dataclasses.py\", line 334, in _freeze\r\n assert isinstance(var, Var)\r\nAssertionError: \r\nfoo.py:10: : note: use --pdb to drop into pdb\r\n```\r\n\r\nI know that the input code does not make sense, but I assume you are still interested in not crashing in even in this case.","author":{"url":"https://github.com/karlb","@type":"Person","name":"karlb"},"datePublished":"2020-06-09T09:29:54Z","url":"https://github.com/python/mypy/issues/8976"}
| 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:2295c178-d5b7-1a1a-6df3-0b986b23f2d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE60:1F52F6:9AD6FF:CF7C1A:6B004557 |
| html-safe-nonce | e022325205e8dfa3676e0d5b26ea2840a93347db4349e47a89b2951ac0584d67 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTYwOjFGNTJGNjo5QUQ2RkY6Q0Y3QzFBOjZCMDA0NTU3IiwidmlzaXRvcl9pZCI6IjUzMzg1NTA0Njg2NjIyMDM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1cf83eed13a9eacfcecb8f4e8887c7f1894f9954cb806829a0268dc1ac09f94f |
| hovercard-subject-tag | issue:635269554 |
| 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/8976/issue_layout |
| twitter:image | https://opengraph.githubassets.com/412cd70e95284cabc96ac513901782e2428ba9acd283643d3b147200529a71ee/python/mypy/issues/8976 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/412cd70e95284cabc96ac513901782e2428ba9acd283643d3b147200529a71ee/python/mypy/issues/8976 |
| og:image:alt | Running mypy on this from dataclasses import dataclass @dataclass(frozen=True) class Foo: attr: int @dataclass(frozen=True) class Bar(Foo): def attr(self) -> int: return 1 produces the following er... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | karlb |
| 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