Title: Crash with Generic Class and Dict · Issue #18996 · python/mypy · GitHub
Open Graph Title: Crash with Generic Class and Dict · Issue #18996 · python/mypy
X Title: Crash with Generic Class and Dict · Issue #18996 · python/mypy
Description: Crash Report I first encountered the bug on a project where I had just started trying to implement the new generic type syntax introduced in Python 3.12. I initially saw this bug with mypy 1.15 but it also occurs on the current master br...
Open Graph Description: Crash Report I first encountered the bug on a project where I had just started trying to implement the new generic type syntax introduced in Python 3.12. I initially saw this bug with mypy 1.15 but...
X Description: Crash Report I first encountered the bug on a project where I had just started trying to implement the new generic type syntax introduced in Python 3.12. I initially saw this bug with mypy 1.15 but...
Opengraph URL: https://github.com/python/mypy/issues/18996
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash with Generic Class and Dict","articleBody":"**Crash Report**\n\nI first encountered the bug on a project where I had just started trying to implement the new generic type syntax introduced in Python 3.12. I initially saw this bug with mypy 1.15 but it also occurs on the current master branch.\n\n**Traceback**\n\n```\nrepro.py:5: error: INTERNAL ERROR -- Please try using mypy master on GitHub:\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\nPlease report a bug at https://github.com/python/mypy/issues\nversion: 1.16.0+dev.7b4f6311e29452cc8d4ddb78331d0047c8b17e93\nTraceback (most recent call last):\n File \"/home/matthew/code/mypy/venv/bin/mypy\", line 8, in \u003cmodule>\n sys.exit(console_entry())\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/__main__.py\", line 15, in console_entry\n main()\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/main.py\", line 127, in main\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/main.py\", line 211, in run_build\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/build.py\", line 191, in build\n result = _build(\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/build.py\", line 267, in _build\n graph = dispatch(sources, manager, stdout)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/build.py\", line 2939, in dispatch\n process_graph(graph, manager)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/build.py\", line 3337, in process_graph\n process_stale_scc(graph, scc, manager)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/build.py\", line 3438, in process_stale_scc\n graph[id].type_check_first_pass()\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/build.py\", line 2311, in type_check_first_pass\n self.type_checker().check_first_pass()\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 472, in check_first_pass\n self.accept(d)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 579, in accept\n stmt.accept(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1200, in accept\n return visitor.visit_class_def(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 2536, in visit_class_def\n self.accept(defn.defs)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 579, in accept\n stmt.accept(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1281, in accept\n return visitor.visit_block(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 3025, in visit_block\n self.accept(s)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 579, in accept\n stmt.accept(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/nodes.py\", line 813, in accept\n return visitor.visit_func_def(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 1129, in visit_func_def\n self._visit_func_def(defn)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 1133, in _visit_func_def\n self.check_func_item(defn, name=defn.name)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 1168, in check_func_item\n self.check_func_def(defn, typ, name, allow_empty)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 1455, in check_func_def\n self.accept(item.body)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 579, in accept\n stmt.accept(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1281, in accept\n return visitor.visit_block(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 3025, in visit_block\n self.accept(s)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 579, in accept\n stmt.accept(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1301, in accept\n return visitor.visit_expression_stmt(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checker.py\", line 4711, in visit_expression_stmt\n expr_type = self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 5962, in accept\n typ = self.visit_call_expr(node, allow_none_return=True)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 488, in visit_call_expr\n return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 578, in visit_call_expr_inner\n self.accept(e.callee, type_context, always_allow_any=True, is_callee=True)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 5970, in accept\n typ = node.accept(self)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1914, in accept\n return visitor.visit_member_expr(self)\n ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 3342, in visit_member_expr\n result = self.analyze_ordinary_member_access(e, is_lvalue)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 3372, in analyze_ordinary_member_access\n member_type = analyze_member_access(\n e.name,\n ...\u003c10 lines>...\n rvalue=rvalue,\n )\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkmember.py\", line 219, in analyze_member_access\n result = _analyze_member_access(name, typ, mx, override_info)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkmember.py\", line 238, in _analyze_member_access\n return analyze_instance_member_access(name, typ, mx, override_info)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkmember.py\", line 360, in analyze_instance_member_access\n signature = check_self_arg(\n signature, mx.self_type, method.is_class, mx.context, name, mx.msg\n )\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/checkmember.py\", line 1038, in check_self_arg\n if subtypes.is_subtype(\n ~~~~~~~~~~~~~~~~~~~^\n dispatched_arg_type,\n ^^^^^^^^^^^^^^^^^^^^\n ...\u003c6 lines>...\n ignore_pos_arg_names=True,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n ):\n ^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 188, in is_subtype\n return _is_subtype(left, right, subtype_context, proper_subtype=False)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 355, in _is_subtype\n return left.accept(SubtypeVisitor(orig_right, subtype_context, proper_subtype))\n ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/types.py\", line 1475, in accept\n return visitor.visit_instance(self)\n ~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 573, in visit_instance\n infer_class_variances(right.type)\n ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 2152, in infer_class_variances\n if not infer_variance(info, i):\n ~~~~~~~~~~~~~~^^^^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 2114, in infer_variance\n if not is_subtype(typ, typ2):\n ~~~~~~~~~~^^^^^^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 188, in is_subtype\n return _is_subtype(left, right, subtype_context, proper_subtype=False)\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 355, in _is_subtype\n return left.accept(SubtypeVisitor(orig_right, subtype_context, proper_subtype))\n ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/types.py\", line 3039, in accept\n return visitor.visit_partial_type(self)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n File \"/home/matthew/code/mypy/venv/lib/python3.13/site-packages/mypy/subtypes.py\", line 1088, in visit_partial_type\n raise RuntimeError(f'Partial type \"{left}\" cannot be checked with \"issubtype()\"')\nRuntimeError: Partial type \"\u003cpartial dict[?, ?]>\" cannot be checked with \"issubtype()\"\nrepro.py:5: : note: use --pdb to drop into pdb\n```\n\n**To Reproduce**\n\n`$ mypy repro.py`\n\n`repro.py`:\n```python\nclass Repro[T]:\n def __init__(self, v) -> None:\n self.storage = {}\n\n self.foo()\n\n def foo(self):\n pass\n```\nThis is as minimal as I could get it.\n\n**Your Environment**\n\n- Mypy version used: mypy 1.16.0+dev.7b4f6311e29452cc8d4ddb78331d0047c8b17e93 (compiled: no)\n- Mypy command-line flags: None\n- Mypy configuration options from `mypy.ini` (and other config files): None\n- Python version used: Python 3.13.2\n- Operating system and version: Manjaro Linux\n","author":{"url":"https://github.com/mscheifer","@type":"Person","name":"mscheifer"},"datePublished":"2025-04-29T01:44:53Z","url":"https://github.com/python/mypy/issues/18996"}
| 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:2c329033-70c4-8270-7135-6fd75a4446a9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDB6:3204C8:2F851AC:3EC15F0:6B0027F5 |
| html-safe-nonce | 39ada4a9d8049fc7abab2d98cf65ed0c8ea399ad496af490cb7380ea760f7367 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREI2OjMyMDRDODoyRjg1MUFDOjNFQzE1RjA6NkIwMDI3RjUiLCJ2aXNpdG9yX2lkIjoiODYzNzg0ODUxNDUwOTk0MDcyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 43967dd146921ed18979e8db0ce743191f963ea66d6c6414f0529b666b9e4d59 |
| hovercard-subject-tag | issue:3026716615 |
| 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/18996/issue_layout |
| twitter:image | https://opengraph.githubassets.com/251afbd8eadb8f593c0f1c31b96c18575ff55f172e67a3b71e142034944cd2ef/python/mypy/issues/18996 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/251afbd8eadb8f593c0f1c31b96c18575ff55f172e67a3b71e142034944cd2ef/python/mypy/issues/18996 |
| og:image:alt | Crash Report I first encountered the bug on a project where I had just started trying to implement the new generic type syntax introduced in Python 3.12. I initially saw this bug with mypy 1.15 but... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mscheifer |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width