Title: Unclear when Join is picked vs Union in upcast operation. · Issue #19652 · python/mypy · GitHub
Open Graph Title: Unclear when Join is picked vs Union in upcast operation. · Issue #19652 · python/mypy
X Title: Unclear when Join is picked vs Union in upcast operation. · Issue #19652 · python/mypy
Description: I noticed some rather erratic behavior when sometimes it picks union and other times the join. from typing import Iterable class A: ... class B: ... class C: ... def upcast[T](arg: Iterable[T]) -> Iterable[T]: return arg def test_builtin...
Open Graph Description: I noticed some rather erratic behavior when sometimes it picks union and other times the join. from typing import Iterable class A: ... class B: ... class C: ... def upcast[T](arg: Iterable[T]) -> ...
X Description: I noticed some rather erratic behavior when sometimes it picks union and other times the join. from typing import Iterable class A: ... class B: ... class C: ... def upcast[T](arg: Iterable[T]) -&g...
Opengraph URL: https://github.com/python/mypy/issues/19652
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unclear when Join is picked vs Union in upcast operation.","articleBody":"I noticed some rather erratic behavior when sometimes it picks union and other times the join.\n\n```python\nfrom typing import Iterable\n\nclass A: ...\nclass B: ...\nclass C: ...\n\ndef upcast[T](arg: Iterable[T]) -\u003e Iterable[T]: return arg\n\ndef test_builtin(x: tuple[int, str, None]) -\u003e None:\n reveal_type(upcast(x)) # Iterable[str | int | None]\n\ndef test_custom(x: tuple[A, B, C]) -\u003e None:\n reveal_type(upcast(x)) # Iterable[object]\n\ndef test_mixed1(x: tuple[A, str, None]) -\u003e None:\n reveal_type(upcast(x)) # Iterable[str | A | None]\n\ndef test_mixed2(x: tuple[int, str, C]) -\u003e None:\n reveal_type(upcast(x)) # Iterable[object]\n```\n\nhttps://mypy-play.net/?mypy=latest\u0026python=3.12\u0026gist=833674a36174c4140a89645b609da8a9","author":{"url":"https://github.com/randolf-scholz","@type":"Person","name":"randolf-scholz"},"datePublished":"2025-08-13T14:15:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/19652/mypy/issues/19652"}
| 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:1d267227-30fa-e914-7fa9-50903862643a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB1A:3A4C6B:7B6ABC:A68277:6A629AAC |
| html-safe-nonce | 8723dde698dd1ac51640dd6c376b560bd7a07d89f3455ddacfdbfa3d66b0613b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjFBOjNBNEM2Qjo3QjZBQkM6QTY4Mjc3OjZBNjI5QUFDIiwidmlzaXRvcl9pZCI6IjQyNjAyMDgxNzg5OTc5MjY1NzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c2869e17c400f46a751f1339a2089fd68306350a9c7aede97741db76f4e26e3d |
| hovercard-subject-tag | issue:3318652864 |
| 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/19652/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b900c3fcbafd5107fd831a6004801dd21339bb0820d740dde44fb285df92af9/python/mypy/issues/19652 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b900c3fcbafd5107fd831a6004801dd21339bb0820d740dde44fb285df92af9/python/mypy/issues/19652 |
| og:image:alt | I noticed some rather erratic behavior when sometimes it picks union and other times the join. from typing import Iterable class A: ... class B: ... class C: ... def upcast[T](arg: Iterable[T]) -> ... |
| 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 | 10ffaff7e212112a3b4eeb224665f909dff951514db9af4f00de33b681024427 |
| 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 | e470e2fc66e1ac7f528caec0fd8825047788d563 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width