Title: Several dataclass crashes involving Final attributes · Issue #10090 · python/mypy · GitHub
Open Graph Title: Several dataclass crashes involving Final attributes · Issue #10090 · python/mypy
X Title: Several dataclass crashes involving Final attributes · Issue #10090 · python/mypy
Description: Crash Report I was just trying things out and found a crash with: from dataclasses import dataclass from typing import Final @dataclass class FirstClass: FIRST_CONST: Final = 3 @dataclass # mypy runs fine if this isn't a dataclass class ...
Open Graph Description: Crash Report I was just trying things out and found a crash with: from dataclasses import dataclass from typing import Final @dataclass class FirstClass: FIRST_CONST: Final = 3 @dataclass # mypy ru...
X Description: Crash Report I was just trying things out and found a crash with: from dataclasses import dataclass from typing import Final @dataclass class FirstClass: FIRST_CONST: Final = 3 @dataclass # mypy ru...
Opengraph URL: https://github.com/python/mypy/issues/10090
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Several dataclass crashes involving Final attributes","articleBody":"\u003c!--\r\n Use this form only if mypy reports an \"INTERNAL ERROR\" and/or gives a traceback.\r\n Please include the traceback and all other messages below (use `mypy --show-traceback`).\r\n-->\r\n\r\n**Crash Report**\r\n\r\nI was just trying things out and found a crash with:\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nfrom typing import Final\r\n\r\n@dataclass\r\nclass FirstClass:\r\n FIRST_CONST: Final = 3\r\n\r\n@dataclass # mypy runs fine if this isn't a dataclass\r\nclass SecondClass:\r\n SECOND_CONST: Final = FirstClass.FIRST_CONST\r\n```\r\n\r\nNote: I don't think this code is very usable. I think I would want `ClassVar` here (or just a module-scoped variable), but thought the report might be interesting all the same.\r\n\r\n**Traceback**\r\n\r\nTraceback on current master:\r\n\r\n```https://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.820+dev.88dde657fedecf17e15222ad4b685b0aeddcc423\r\nTraceback (most recent call last):\r\n File \"/home/mjh/.pyenv/versions/3.8.6/bin/mypy\", line 33, in \u003cmodule>\r\n sys.exit(load_entry_point('mypy', 'console_scripts', 'mypy')())\r\n File \"/home/mjh/src/mypy/mypy/__main__.py\", line 11, in console_entry\r\n main(None, sys.stdout, sys.stderr)\r\n File \"/home/mjh/src/mypy/mypy/main.py\", line 98, in main\r\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\r\n File \"/home/mjh/src/mypy/mypy/build.py\", line 179, in build\r\n result = _build(\r\n File \"/home/mjh/src/mypy/mypy/build.py\", line 253, in _build\r\n graph = dispatch(sources, manager, stdout)\r\n File \"/home/mjh/src/mypy/mypy/build.py\", line 2658, in dispatch\r\n process_graph(graph, manager)\r\n File \"/home/mjh/src/mypy/mypy/build.py\", line 2982, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/home/mjh/src/mypy/mypy/build.py\", line 3074, in process_stale_scc\r\n mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)\r\n File \"/home/mjh/src/mypy/mypy/semanal_main.py\", line 78, in semantic_analysis_for_scc\r\n process_top_levels(graph, scc, patches)\r\n File \"/home/mjh/src/mypy/mypy/semanal_main.py\", line 199, in process_top_levels\r\n deferred, incomplete, progress = semantic_analyze_target(next_id, state,\r\n File \"/home/mjh/src/mypy/mypy/semanal_main.py\", line 326, in semantic_analyze_target\r\n analyzer.refresh_partial(refresh_node,\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 394, in refresh_partial\r\n self.refresh_top_level(node)\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 405, in refresh_top_level\r\n self.accept(d)\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 4835, in accept\r\n node.accept(self)\r\n File \"/home/mjh/src/mypy/mypy/nodes.py\", line 950, in accept\r\n return visitor.visit_class_def(self)\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 1048, in visit_class_def\r\n self.analyze_class(defn)\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 1125, in analyze_class\r\n self.analyze_class_body_common(defn)\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 1134, in analyze_class_body_common\r\n self.apply_class_plugin_hooks(defn)\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 1180, in apply_class_plugin_hooks\r\n hook(ClassDefContext(defn, decorator, self))\r\n File \"/home/mjh/src/mypy/mypy/plugins/dataclasses.py\", line 361, in dataclass_class_maker_callback\r\n transformer.transform()\r\n File \"/home/mjh/src/mypy/mypy/plugins/dataclasses.py\", line 106, in transform\r\n ctx.api.defer()\r\n File \"/home/mjh/src/mypy/mypy/semanal.py\", line 4554, in defer\r\n assert not self.final_iteration, 'Must not defer during final iteration'\r\nAssertionError: Must not defer during final iteration\r\n/home/mjh/tmp/testing_py/mypy_test.py:9: : note: use --pdb to drop into pdb\r\n```\r\n\r\nTraceback on pip package:\r\n\r\n```\r\nmypy_test.py:9: 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.800\r\nTraceback (most recent call last):\r\n File \"mypy/semanal.py\", line 4835, in accept\r\n File \"mypy/nodes.py\", line 950, in accept\r\n File \"mypy/semanal.py\", line 1048, in visit_class_def\r\n File \"mypy/semanal.py\", line 1125, in analyze_class\r\n File \"mypy/semanal.py\", line 1134, in analyze_class_body_common\r\n File \"mypy/semanal.py\", line 1180, in apply_class_plugin_hooks\r\n File \"mypy/plugins/dataclasses.py\", line 361, in dataclass_class_maker_callback\r\n File \"mypy/plugins/dataclasses.py\", line 106, in transform\r\n File \"mypy/semanal.py\", line 4554, in defer\r\nAssertionError: Must not defer during final iteration\r\nmypy_test.py:9: : note: use --pdb to drop into pdb\r\n```\r\n\r\n**To Reproduce**\r\n\r\nRun `mypy` over a file containing the content above.\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n- Mypy version used: 0.820+dev.88dde657fedecf17e15222ad4b685b0aeddcc423 and 0.800\r\n- Mypy command-line flags: None\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: 3.8.6\r\n- Operating system and version: Debian GNU/Linux 10 (buster)\r\n\r\n\u003c!--\r\nYou can freely edit this text, please remove all the lines\r\nyou believe are unnecessary.\r\n-->\r\n","author":{"url":"https://github.com/matthewhughes934","@type":"Person","name":"matthewhughes934"},"datePublished":"2021-02-13T17:12:34Z","url":"https://github.com/python/mypy/issues/10090"}
| 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:5c2db8ea-4fd0-d332-06ee-75b1e6a7abdf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC52:3E1398:26AFA2:344236:6B00240B |
| html-safe-nonce | 654267062818992d9e2858f5e9113ec4751b64faa0f84c25f1930e072094d906 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzUyOjNFMTM5ODoyNkFGQTI6MzQ0MjM2OjZCMDAyNDBCIiwidmlzaXRvcl9pZCI6IjM4OTk0OTU2NzI3NzYyMzgwOTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6642c215480fd6fc5d8f7a41a7e5c869f4e0c848333cd795aa43cbc2ed4b4efb |
| hovercard-subject-tag | issue:807788070 |
| 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/10090/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90e318c60c1055e533f08a18dfc874169bae65c4da94f5801cdb6a447baae120/python/mypy/issues/10090 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90e318c60c1055e533f08a18dfc874169bae65c4da94f5801cdb6a447baae120/python/mypy/issues/10090 |
| og:image:alt | Crash Report I was just trying things out and found a crash with: from dataclasses import dataclass from typing import Final @dataclass class FirstClass: FIRST_CONST: Final = 3 @dataclass # mypy ru... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matthewhughes934 |
| 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