Title: Use Union for tuple fallback? · Issue #7616 · python/mypy · GitHub
Open Graph Title: Use Union for tuple fallback? · Issue #7616 · python/mypy
X Title: Use Union for tuple fallback? · Issue #7616 · python/mypy
Description: Please insert below the code you are checking with mypy, from typing import Iterable, Iterator, Union from typing_extensions import Protocol class MixedIter(Protocol): def __iter__(self) -> Iterator[Union[int, str]]: ... def f(xs: Iterab...
Open Graph Description: Please insert below the code you are checking with mypy, from typing import Iterable, Iterator, Union from typing_extensions import Protocol class MixedIter(Protocol): def __iter__(self) -> Iterato...
X Description: Please insert below the code you are checking with mypy, from typing import Iterable, Iterator, Union from typing_extensions import Protocol class MixedIter(Protocol): def __iter__(self) -> Iter...
Opengraph URL: https://github.com/python/mypy/issues/7616
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use Union for tuple fallback?","articleBody":"* Please insert below the code you are checking with mypy,\r\n\r\n```py\r\nfrom typing import Iterable, Iterator, Union\r\nfrom typing_extensions import Protocol\r\n\r\nclass MixedIter(Protocol):\r\n def __iter__(self) -> Iterator[Union[int, str]]: ...\r\n\r\ndef f(xs: Iterable[Union[int, str]]) -> str:\r\n return ''.join(str(x) for x in xs)\r\n\r\ndef g(xs: MixedIter) -> str:\r\n return ''.join(str(x) for x in xs)\r\n\r\nmixedTuple = (56, 'A')\r\nreveal_type(mixedTuple)\r\nreveal_type(mixedTuple.__iter__)\r\nprint(f(mixedTuple))\r\nprint(g(mixedTuple))\r\n```\r\n\r\n* What is the actual behavior/output?\r\n\r\n```\r\nmixedtuple.py:14: note: Revealed type is 'Tuple[builtins.int, builtins.str]'\r\nmixedtuple.py:15: note: Revealed type is 'def () -> typing.Iterator[builtins.object*]'\r\nmixedtuple.py:17: error: Argument 1 to \"g\" has incompatible type \"Tuple[int, str]\"; expected \"MixedIter\" [arg-type]\r\n```\r\n\r\n* What is the behavior/output you expect?\r\n\r\nI'd expect both `f(mixedTuple)` and `g(mixedTuple)` to be accepted without errors.\r\n\r\n* What are the versions of mypy and Python you are using?\r\n\r\nmypy 0.730 on Python 3.7.2.\r\n","author":{"url":"https://github.com/mthuurne","@type":"Person","name":"mthuurne"},"datePublished":"2019-10-03T09:52:48Z","url":"https://github.com/python/mypy/issues/7616"}
| 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:69b61b95-5250-6554-35b3-c177a29bfb83 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AC2:196792:3486ABB:45FE4C1:6B004822 |
| html-safe-nonce | e0fb7e45cd9ccbdf2f179ac282b3b8cd8a788df4fb66828bd350676022b7c030 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUMyOjE5Njc5MjozNDg2QUJCOjQ1RkU0QzE6NkIwMDQ4MjIiLCJ2aXNpdG9yX2lkIjoiOTkzMjc0NzMzMDM2MzI0ODk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 48f8fb52859ec9ecd308e5e44d850e737c1fb7d06a901f8bc8ff2ae4e3f031bf |
| hovercard-subject-tag | issue:501964796 |
| 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/7616/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bf298d81b1e7259333374a7db1ebcef1dc4712bf809a1438414b25e346c3b83c/python/mypy/issues/7616 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bf298d81b1e7259333374a7db1ebcef1dc4712bf809a1438414b25e346c3b83c/python/mypy/issues/7616 |
| og:image:alt | Please insert below the code you are checking with mypy, from typing import Iterable, Iterator, Union from typing_extensions import Protocol class MixedIter(Protocol): def __iter__(self) -> Iterato... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mthuurne |
| 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