Title: Mypy thinks `dict[Never, Never]` is a subtype of `Mapping[str, object]` · Issue #19641 · python/mypy · GitHub
Open Graph Title: Mypy thinks `dict[Never, Never]` is a subtype of `Mapping[str, object]` · Issue #19641 · python/mypy
X Title: Mypy thinks `dict[Never, Never]` is a subtype of `Mapping[str, object]` · Issue #19641 · python/mypy
Description: This behaves as expected: https://mypy-play.net/?mypy=latest&python=3.12&gist=8718e96550599dc3ae48a13879005762 from typing import Mapping, Never def upcast(d: dict[Never, Never]) -> Mapping[str, object]: return d # E: [return-value] (✅ e...
Open Graph Description: This behaves as expected: https://mypy-play.net/?mypy=latest&python=3.12&gist=8718e96550599dc3ae48a13879005762 from typing import Mapping, Never def upcast(d: dict[Never, Never]) -> Mapping[str, ob...
X Description: This behaves as expected: https://mypy-play.net/?mypy=latest&python=3.12&gist=8718e96550599dc3ae48a13879005762 from typing import Mapping, Never def upcast(d: dict[Never, Never]) -> Mapp...
Opengraph URL: https://github.com/python/mypy/issues/19641
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy thinks `dict[Never, Never]` is a subtype of `Mapping[str, object]`","articleBody":"This behaves as expected: https://mypy-play.net/?mypy=latest&python=3.12&gist=8718e96550599dc3ae48a13879005762\n\n```python\nfrom typing import Mapping, Never\n\ndef upcast(d: dict[Never, Never]) -> Mapping[str, object]:\n return d # E: [return-value] (✅ expected)\n```\n\nBut it breaks here (due to caching?) https://mypy-play.net/?mypy=latest&python=3.12&gist=6199ba50b6b02e2350e70cb3a8ff4bba\n\n```python\nfrom typing import Mapping, Never\n\ndef get[M: Mapping[str, object]](arg: M, /) -> M:\n return arg\n\nreveal_type(get({})) # dict[Never, Never] (❌ incorrect)\n\ndef upcast(d: dict[Never, Never]) -> Mapping[str, object]:\n return d # \u003c-- No error anymore 😱\n```","author":{"url":"https://github.com/randolf-scholz","@type":"Person","name":"randolf-scholz"},"datePublished":"2025-08-11T20:06:22Z","url":"https://github.com/python/mypy/issues/19641"}
| 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:8e9d53d4-9234-43da-d104-2c4adf5a6130 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B9E:2C45C0:4D67A7:6CB8A4:6B007485 |
| html-safe-nonce | d8db65e02056442704e33fde01efaaf16109ceb9639c88a3886a5aac060d3af5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjlFOjJDNDVDMDo0RDY3QTc6NkNCOEE0OjZCMDA3NDg1IiwidmlzaXRvcl9pZCI6IjgzMzM5MDEwMjMzNjYxMTY0ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 04ee66ce3895fae99cdb6e370eab0ef0d0d91b162b9dfd5a7382b06b708e0899 |
| hovercard-subject-tag | issue:3311504103 |
| 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/19641/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84d1c43692150d61b0d47cffb71f2f6e2a88aedd082f38d174cbddb45fc4e0f5/python/mypy/issues/19641 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84d1c43692150d61b0d47cffb71f2f6e2a88aedd082f38d174cbddb45fc4e0f5/python/mypy/issues/19641 |
| og:image:alt | This behaves as expected: https://mypy-play.net/?mypy=latest&python=3.12&gist=8718e96550599dc3ae48a13879005762 from typing import Mapping, Never def upcast(d: dict[Never, Never]) -> Mapping[str, ob... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | randolf-scholz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| 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 | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width