René's URL Explorer Experiment


Title: mypyc generated `__ne__` uses `self` type instead of `__eq__`'s RHS type with strict dunder typing · Issue #21568 · python/mypy · GitHub

Open Graph Title: mypyc generated `__ne__` uses `self` type instead of `__eq__`'s RHS type with strict dunder typing · Issue #21568 · python/mypy

X Title: mypyc generated `__ne__` uses `self` type instead of `__eq__`'s RHS type with strict dunder typing · Issue #21568 · python/mypy

Description: Bug Report While testing fixes for #21566 , I tried to set strict_dunder_typing=True which allowed me to somewhat narrow the issue down, and I've sinced removed this bool. However it did expose a seemingly other issue. When mypyc implici...

Open Graph Description: Bug Report While testing fixes for #21566 , I tried to set strict_dunder_typing=True which allowed me to somewhat narrow the issue down, and I've sinced removed this bool. However it did expose a s...

X Description: Bug Report While testing fixes for #21566 , I tried to set strict_dunder_typing=True which allowed me to somewhat narrow the issue down, and I've sinced removed this bool. However it did expose...

Opengraph URL: https://github.com/python/mypy/issues/21568

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypyc generated `__ne__` uses `self` type instead of `__eq__`'s RHS type with strict dunder typing","articleBody":"**Bug Report**\n\nWhile testing fixes for #21566 , I tried to set `strict_dunder_typing=True` which allowed me to somewhat narrow the issue down, and I've sinced removed this bool. However it did expose a seemingly other issue.\n\nWhen mypyc implicitly generates `__ne__` from a user-defined `__eq__` with `strict_dunder_typing=True`, the generated `__ne__` appears to use the type of `self` as the type of its right-hand-side argument.\n\nI may be misunderstanding the intended behavior of `strict_dunder_typing`, but my expectation is that the generated `__ne__` should mirror the argument type of `__eq__`'s other parameter. In other words, if `__eq__` accepts a particular set of object types, then the generated `__ne__` should also accept that same set of object types.\n\n**To Reproduce**\n\nAdd this test case to `mypyc/test-data/run-dunders.test`:\n\n```\n[case testDundersImplicitNeWithNarrowRhs]\nclass Accepted:\n    pass\n\nclass Eq:\n    def __eq__(self, other: Accepted) -> bool:  # type: ignore[override]\n        return True\n\ndef test_implicit_ne_with_narrow_rhs() -> None:\n    assert Eq() == Accepted()\n    assert not (Eq() != Accepted())\n```\n\nRun the strict dunder tests:\n\n```\npython -m pytest -q mypyc/test/test_run.py -k testDundersImplicitNeWithNarrowRhs\n```\n\n**Expected Behavior**\n\nBoth comparisons should work.\n\nSince `__eq__` is defined as:\n\n```python\ndef __eq__(self, other: Accepted) -> bool:\n    return True\n```\n\nthe generated `__ne__` should accept the same other type and behave as though it were approximately:\n\n```python\ndef __ne__(self, other: Accepted) -> bool:\n    return not self.__eq__(other)\n```\n\nSo this should pass:\n\n```python\nassert Eq() == Accepted()\nassert not (Eq() != Accepted())\n```\n\n**Actual Behavior**\n\nThe `==` comparison succeeds, but the `!=` comparison fails at runtime because the implicitly generated `__ne__` expects the right-hand-side argument to be `Eq`.\n\nIn other words, the generated `__ne__` appears to behave as though its RHS argument type came from `self`, not from `__eq__`'s other parameter.\n","author":{"url":"https://github.com/rheard","@type":"Person","name":"rheard"},"datePublished":"2026-05-30T04:46:52Z","url":"https://github.com/python/mypy/issues/21568"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dab68678-ca07-7c29-e670-d87fcfa116bf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8C6A:2A4B31:386334:4C5854:6B002A20
html-safe-noncec964294db5e9c72919d16aa5d78f68d3ac5b76e9b784bd5c78cc2e0d6c9e96d3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzZBOjJBNEIzMTozODYzMzQ6NEM1ODU0OjZCMDAyQTIwIiwidmlzaXRvcl9pZCI6IjgwNzQwNjM2NjY2OTA5MjcxMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace12b9ec46e361bf6f431a00ce6cf0f1382ab5b5224831cc1da68859d96e29cbd
hovercard-subject-tagissue:4553241201
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/21568/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a7bf3669327c71ed4afe8eeab5747e5330d719077254b1c2e2a0651079e4f96d/python/mypy/issues/21568
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a7bf3669327c71ed4afe8eeab5747e5330d719077254b1c2e2a0651079e4f96d/python/mypy/issues/21568
og:image:altBug Report While testing fixes for #21566 , I tried to set strict_dunder_typing=True which allowed me to somewhat narrow the issue down, and I've sinced removed this bool. However it did expose a s...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerheard
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/21568#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F21568
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F21568
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/21568
Reloadhttps://github.com/python/mypy/issues/21568
Reloadhttps://github.com/python/mypy/issues/21568
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests547 (547)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/21568
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/21568
#21569https://github.com/python/mypy/pull/21569
mypyc generated __ne__ uses self type instead of __eq__'s RHS type with strict dunder typinghttps://github.com/python/mypy/issues/21568#top
#21569https://github.com/python/mypy/pull/21569
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/rheard
rheardhttps://github.com/rheard
on May 30, 2026https://github.com/python/mypy/issues/21568#issue-4553241201
#21566https://github.com/python/mypy/issues/21566
rheardhttps://github.com/rheard
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on May 30, 2026https://github.com/python/mypy/issues/21568#event-26136516823
https://github.com/rheard
rheardhttps://github.com/rheard
on May 30, 2026https://github.com/python/mypy/issues/21568#issuecomment-4581694298
https://github.com/rheard
rheardhttps://github.com/rheard
on May 31, 2026https://github.com/python/mypy/issues/21568#issuecomment-4588213537
p-sawickihttps://github.com/p-sawicki
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#21569https://github.com/python/mypy/pull/21569
on Jun 1, 2026https://github.com/python/mypy/issues/21568#event-26194188055
p-sawickihttps://github.com/p-sawicki
on Jun 1, 2026https://github.com/python/mypy/issues/21568#event-26194188085
[mypyc] Use `other` arg instead of `self` for RHS type (#21569)https://github.com/python/mypy/commit/cd75c4ec10254f4c98964308a0a1437274c7be4f
#21569https://github.com/python/mypy/pull/21569
https://docs.github.com/articles/closing-issues-via-commit-messages
cd75c4ehttps://github.com/python/mypy/commit/cd75c4ec10254f4c98964308a0a1437274c7be4f
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/21568
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/21568
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.