Title: Corner case causes arg-type error: type is incompatible with itself · Issue #20608 · python/mypy · GitHub
Open Graph Title: Corner case causes arg-type error: type is incompatible with itself · Issue #20608 · python/mypy
X Title: Corner case causes arg-type error: type is incompatible with itself · Issue #20608 · python/mypy
Description: Bug Report With a very specific combination of features, Mypy rejects a decorator application, claiming that a callable type is incompatible with apparently the same callable type. To Reproduce from collections.abc import Callable from t...
Open Graph Description: Bug Report With a very specific combination of features, Mypy rejects a decorator application, claiming that a callable type is incompatible with apparently the same callable type. To Reproduce fro...
X Description: Bug Report With a very specific combination of features, Mypy rejects a decorator application, claiming that a callable type is incompatible with apparently the same callable type. To Reproduce fro...
Opengraph URL: https://github.com/python/mypy/issues/20608
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Corner case causes arg-type error: type is incompatible with itself","articleBody":"\u003c!--\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\nPlease consider:\n\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\n- asking on gitter chat: https://gitter.im/python/typing\n-->\n\n**Bug Report**\n\n\u003c!--\nIf you're reporting a problem with a specific library function, the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues\n\nIf the project you encountered the issue in is open source, please provide a link to the project.\n-->\n\nWith a very specific combination of features, Mypy rejects a decorator application, claiming that a callable type is incompatible with apparently the same callable type.\n\n**To Reproduce**\n\n```python\nfrom collections.abc import Callable\nfrom typing import Never\n\nimport attrs\n\n\n# In the actual implementation, most classes are attrs classes, but this\n# appears to be the only one needed to make the bug manifest.\n@attrs.frozen\nclass ValueTerm[F]:\n pass\n\n\nclass ValueType[F]:\n pass\n\n\nclass Bundle[T]:\n data: T\n\n\nclass AlmostNever:\n \"\"\"Replacing Never with this makes the bug disappear.\n\n At least, at this level of replication. Paring it down further causes weird\n behavior changes.\n \"\"\"\n\n\ndef bundlemethod[T, U](method: Callable[[Bundle[T]], U]) -> Callable[[T], U]:\n raise NotImplementedError\n\n\n@bundlemethod\ndef fail_value_type_inference[F](\n self_bundle: Bundle[ValueTerm[F]], /\n) -> (\n tuple[Never, Bundle[ValueType[F]]] | tuple[int, Bundle[ValueType[F | str]]]\n):\n raise NotImplementedError\n\n```\n\nThe code that hit this was using `Generator` instead of `tuple`.\n\n**Actual Behavior**\n\n```\nmypy_repro.py:34: error: Argument 1 to \"bundlemethod\" has incompatible type \"Callable[[Bundle[ValueTerm[F]]], tuple[Never, Bundle[ValueType[F]]] | tuple[int, Bundle[ValueType[F | str]]]]\"; expected \"Callable[[Bundle[ValueTerm[F]]], tuple[Never, Bundle[ValueType[F]]] | tuple[int, Bundle[ValueType[F | str]]]]\" [arg-type]\nFound 1 error in 1 file (checked 1 source file)\n```\n\n\u003c!-- What went wrong? Paste mypy's output. -->\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: `mypy 1.20.0+dev.3cae656ce264f00ac5417b0559a8cba1453f5eb5 (compiled: no)` also encountered with `mypy 1.19.1 (compiled: yes)`\n- Mypy command-line flags: `--strict` or nothing\n- Mypy configuration options from `mypy.ini` (and other config files): Was using unrelated plugin for `deal`, but commented out those lines, and still reproduced.\n- Python version used: `Python 3.13.11`\n\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\n","author":{"url":"https://github.com/mwchase","@type":"Person","name":"mwchase"},"datePublished":"2026-01-17T17:33:05Z","url":"https://github.com/python/mypy/issues/20608"}
| 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:b50e2865-7d74-2e7b-8cd5-87a168d67886 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95B8:1BAA33:17DB595:1F9D884:6B001D9A |
| html-safe-nonce | 4243082a92828886173c2d97d72e29ca4b8c1af8ae9996a5e23df585ae362466 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUI4OjFCQUEzMzoxN0RCNTk1OjFGOUQ4ODQ6NkIwMDFEOUEiLCJ2aXNpdG9yX2lkIjoiNzgxMzUwMDIxMTQzNDYyNjQ1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 64e01b4fa6877e8727ce371ba0b1939c39af71feb4dd7d5501d26cacffac58d8 |
| hovercard-subject-tag | issue:3825564512 |
| 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/20608/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c23581a86302b53a0feaf464a430063f413b276b98423c5e25fac5ec9b45226b/python/mypy/issues/20608 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c23581a86302b53a0feaf464a430063f413b276b98423c5e25fac5ec9b45226b/python/mypy/issues/20608 |
| og:image:alt | Bug Report With a very specific combination of features, Mypy rejects a decorator application, claiming that a callable type is incompatible with apparently the same callable type. To Reproduce fro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mwchase |
| 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