Title: mypyc assertion error when generating `__ne__` from inherited `__eq__` in package import cycle · Issue #21566 · python/mypy · GitHub
Open Graph Title: mypyc assertion error when generating `__ne__` from inherited `__eq__` in package import cycle · Issue #21566 · python/mypy
X Title: mypyc assertion error when generating `__ne__` from inherited `__eq__` in package import cycle · Issue #21566 · python/mypy
Description: Bug Report mypyc can fail with an internal AssertionError when it tries to generate __ne__ from an inherited __eq__. This happens when the inherited method's declaration is available before its FuncIR body has been generated. One way to ...
Open Graph Description: Bug Report mypyc can fail with an internal AssertionError when it tries to generate __ne__ from an inherited __eq__. This happens when the inherited method's declaration is available before its Fun...
X Description: Bug Report mypyc can fail with an internal AssertionError when it tries to generate __ne__ from an inherited __eq__. This happens when the inherited method's declaration is available before its...
Opengraph URL: https://github.com/python/mypy/issues/21566
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypyc assertion error when generating `__ne__` from inherited `__eq__` in package import cycle","articleBody":"**Bug Report**\n\nmypyc can fail with an internal `AssertionError` when it tries to generate `__ne__` from an inherited `__eq__`.\n\nThis happens when the inherited method's declaration is available before its `FuncIR` body has been generated. One way to trigger this is with a package import cycle where `__init__.py` imports a child module before importing the subpackage that defines the base class.\n\n**To Reproduce**\n\nAdd this test case to `mypyc/test-data/run-multimodule.test`:\n\n```\n[case testPackageCycleInheritedEq]\nfrom other.other_child import Child\n\ndef make_child() -> Child:\n return Child()\n\n[file other/__init__.py]\nfrom other.other_child import Child as Child\nfrom other.other_subpkg import Base as Base\n\n[file other/other_child.py]\nfrom other.other_subpkg import Base\n\nclass Child(Base):\n pass\n\n[file other/other_subpkg/__init__.py]\nfrom other.other_subpkg.other_base import Base as Base\n\n[file other/other_subpkg/other_base.py]\nclass Base:\n def __eq__(self, other: object) -> bool:\n return True\n\n[file driver.py]\nfrom native import make_child\nleft = make_child()\nright = make_child()\nassert left == right\nassert not (left != right)\n```\n\nRun:\n\n```\npython -m pytest -q mypyc/test/test_run.py -k testPackageCycleInheritedEq\n```\n\n**Expected Behavior**\n\nmypyc should compile this successfully.\n\nSince `Child` inherits `Base.__eq__` but does not define `__ne__`, mypyc should be able to synthesize `Child.__ne__` from the inherited `__eq__` declaration.\n\n**Actual Behavior**\n\nmypyc fails with an internal assertion error while generating `__ne__`:\n\n```\nmypyc/irbuild/classdef.py:...: in gen_glue_ne_method\n assert func_ir\nAssertionError\n```\n","author":{"url":"https://github.com/rheard","@type":"Person","name":"rheard"},"datePublished":"2026-05-30T03:45:07Z","url":"https://github.com/python/mypy/issues/21566"}
| 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:7652ac83-ed05-2ff0-16e4-8b6f2e186fc3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECC8:396A8E:19EF5E7:226DB69:6B003388 |
| html-safe-nonce | 31bf0944a4f8e8b3d5bbf3f1197c0c3f19892c84802adba0c37402358338c052 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0M4OjM5NkE4RToxOUVGNUU3OjIyNkRCNjk6NkIwMDMzODgiLCJ2aXNpdG9yX2lkIjoiNjkyNzA1OTgxMDk3NDE4NDMyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ddeb5cdf76d006cdd7052dd4359fd40ecf91cb1d516b70fe1e46f7e9f4c5ee78 |
| hovercard-subject-tag | issue:4553093281 |
| 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/21566/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1e667807a17130c0d4c9c8f2773e43afc035b3b8221a0bca3f46befb469641c/python/mypy/issues/21566 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1e667807a17130c0d4c9c8f2773e43afc035b3b8221a0bca3f46befb469641c/python/mypy/issues/21566 |
| og:image:alt | Bug Report mypyc can fail with an internal AssertionError when it tries to generate __ne__ from an inherited __eq__. This happens when the inherited method's declaration is available before its Fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rheard |
| 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