Title: mypy crashes on callable frozen dataclass · Issue #12084 · python/mypy · GitHub
Open Graph Title: mypy crashes on callable frozen dataclass · Issue #12084 · python/mypy
X Title: mypy crashes on callable frozen dataclass · Issue #12084 · python/mypy
Description: Crash Report mypy crashes on callable frozen dataclass Traceback ➜ mypy-bug poetry run mypy mypy_bug/case_3.py --show-traceback mypy_bug/case_3.py:14: error: INTERNAL ERROR -- Please try using mypy master on Github: https://mypy.readthed...
Open Graph Description: Crash Report mypy crashes on callable frozen dataclass Traceback ➜ mypy-bug poetry run mypy mypy_bug/case_3.py --show-traceback mypy_bug/case_3.py:14: error: INTERNAL ERROR -- Please try using mypy...
X Description: Crash Report mypy crashes on callable frozen dataclass Traceback ➜ mypy-bug poetry run mypy mypy_bug/case_3.py --show-traceback mypy_bug/case_3.py:14: error: INTERNAL ERROR -- Please try using mypy...
Opengraph URL: https://github.com/python/mypy/issues/12084
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy crashes on callable frozen dataclass","articleBody":"**Crash Report**\r\n\r\nmypy crashes on callable frozen dataclass\r\n\r\n**Traceback**\r\n\r\n```shell\r\n➜ mypy-bug poetry run mypy mypy_bug/case_3.py --show-traceback\r\nmypy_bug/case_3.py:14: error: INTERNAL ERROR -- Please try using mypy master on Github:\r\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 0.931\r\nTraceback (most recent call last):\r\n File \"mypy/semanal.py\", line 5142, in accept\r\n File \"mypy/nodes.py\", line 1005, in accept\r\n File \"mypy/semanal.py\", line 1105, in visit_class_def\r\n File \"mypy/semanal.py\", line 1184, in analyze_class\r\n File \"mypy/semanal.py\", line 1193, in analyze_class_body_common\r\n File \"mypy/semanal.py\", line 1239, in apply_class_plugin_hooks\r\n File \"mypy/plugins/dataclasses.py\", line 489, in dataclass_class_maker_callback\r\n File \"mypy/plugins/dataclasses.py\", line 194, in transform\r\n File \"mypy/plugins/dataclasses.py\", line 431, in _freeze\r\nAssertionError: \r\nmypy_bug/case_3.py:14: : note: use --pdb to drop into pdb\r\n```\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nfrom typing import Any, Callable\r\n\r\n# here both `Parent` and `Child` are frozen dataclasses\r\n\r\n@dataclass(frozen=True)\r\nclass Parent:\r\n __call__: Callable[..., None]\r\n\r\n def __call__(self, *args: Any, **kwargs: Any) -> None: # type: ignore\r\n raise NotImplementedError\r\n\r\n\r\n@dataclass(frozen=True)\r\nclass Child(Parent):\r\n def __call__(self, value: int) -> None:\r\n ...\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.931\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.10.0\r\n- Operating system and version: macOS Catalina (10.15)\r\n\r\n---\r\n\r\nI'm using \"Guido's hack\" from https://github.com/python/mypy/issues/9560#issuecomment-705955103 which does work in other circumstances:\r\n\r\n```python\r\nfrom typing import Any, Callable\r\n\r\n# here both `Parent` and `Child` are \"regular\" classes\r\n\r\nclass Parent:\r\n __call__: Callable[..., None]\r\n\r\n def __call__(self, *args: Any, **kwargs: Any) -> None: # type: ignore\r\n raise NotImplementedError\r\n\r\n\r\nclass Child(Parent):\r\n def __call__(self, value: int) -> None:\r\n ...\r\n```\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nfrom typing import Any, Callable\r\n\r\n# here `Parent` is a frozen dataclass, but `Child` is not\r\n\r\n@dataclass(frozen=True)\r\nclass Parent:\r\n __call__: Callable[..., None]\r\n\r\n def __call__(self, *args: Any, **kwargs: Any) -> None: # type: ignore\r\n raise NotImplementedError\r\n\r\n\r\nclass Child(Parent):\r\n def __call__(self, value: int) -> None:\r\n ...\r\n```\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nfrom typing import Any, Callable\r\n\r\n# here both `Parent` and `Child` are dataclasses, but not frozen\r\n\r\n@dataclass\r\nclass Parent:\r\n __call__: Callable[..., None]\r\n\r\n def __call__(self, *args: Any, **kwargs: Any) -> None: # type: ignore\r\n raise NotImplementedError\r\n\r\n\r\n@dataclass\r\nclass Child(Parent):\r\n def __call__(self, value: int) -> None:\r\n ...\r\n```","author":{"url":"https://github.com/alexei","@type":"Person","name":"alexei"},"datePublished":"2022-01-27T12:01:53Z","url":"https://github.com/python/mypy/issues/12084"}
| 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:49515da4-cef5-c5bf-ce01-434925f350a0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B26C:163716:248F2E3:31D0E3E:6B00345C |
| html-safe-nonce | 27bece8658528854bd8129bce547b76e9df8443ace4d17ce33f934b6ca3116cf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjZDOjE2MzcxNjoyNDhGMkUzOjMxRDBFM0U6NkIwMDM0NUMiLCJ2aXNpdG9yX2lkIjoiNzYyMDUzMjc1NTM2OTA0NzEzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8e4ff0311dd5a7246b199cec636f84f93c61e804b567e163fddd326c728b5c97 |
| hovercard-subject-tag | issue:1116127000 |
| 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/12084/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2be9cb6d7a04b2b2f6b960d9d98275f64e466f02735ce9f1dd3759af546b4a62/python/mypy/issues/12084 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2be9cb6d7a04b2b2f6b960d9d98275f64e466f02735ce9f1dd3759af546b4a62/python/mypy/issues/12084 |
| og:image:alt | Crash Report mypy crashes on callable frozen dataclass Traceback ➜ mypy-bug poetry run mypy mypy_bug/case_3.py --show-traceback mypy_bug/case_3.py:14: error: INTERNAL ERROR -- Please try using mypy... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexei |
| 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