Title: False-positive "Overloaded function signatures overlap with incompatible return types" · Issue #14770 · python/mypy · GitHub
Open Graph Title: False-positive "Overloaded function signatures overlap with incompatible return types" · Issue #14770 · python/mypy
X Title: False-positive "Overloaded function signatures overlap with incompatible return types" · Issue #14770 · python/mypy
Description: Bug Report In the minimal example below, I get an unexpected "Overloaded function signatures overlap with incompatible return types" error from mypy. The example is taken from a general "wait for an event or a message" function that I us...
Open Graph Description: Bug Report In the minimal example below, I get an unexpected "Overloaded function signatures overlap with incompatible return types" error from mypy. The example is taken from a general "wait for a...
X Description: Bug Report In the minimal example below, I get an unexpected "Overloaded function signatures overlap with incompatible return types" error from mypy. The example is taken from a general &...
Opengraph URL: https://github.com/python/mypy/issues/14770
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False-positive \"Overloaded function signatures overlap with incompatible return types\"","articleBody":"**Bug Report**\r\n\r\nIn the minimal example below, I get an unexpected \"Overloaded function signatures overlap with incompatible return types\" error from mypy. The example is taken from a general \"wait for an event or a message\" function that I use in my codebase. It allows requesting one or multiple event or message types.\r\n\r\n\r\n**To Reproduce**\r\n\r\n```\r\nclass Message:\r\n pass\r\n\r\n\r\nclass Event:\r\n pass\r\n\r\n\r\n_WaitableTypes = Union[type[Message], type[Event]]\r\n_MessageT1 = TypeVar(\"_MessageT1\", bound=Message)\r\n_MessageT2 = TypeVar(\"_MessageT2\", bound=Message)\r\n\r\n\r\n# Single message\r\n@overload\r\ndef wait_for(\r\n msg_type: type[_MessageT1],\r\n) -> _MessageT1:\r\n ...\r\n\r\n\r\n# Two messages (arbitrary iterable of messages is also supported, but not relevant in this example)\r\n@overload\r\ndef wait_for(\r\n msg_type: tuple[type[_MessageT1], type[_MessageT2]],\r\n) -> Union[_MessageT1, _MessageT2]:\r\n ...\r\n\r\n\r\n# List of events\r\n@overload\r\ndef wait_for(\r\n msg_type: Iterable[type[Event]],\r\n) -> Event:\r\n ...\r\n\r\n\r\ndef wait_for(\r\n msg_type: Union[_WaitableTypes, Iterable[_WaitableTypes]],\r\n) -> Union[Message, Event]:\r\n return ... # type: ignore\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nmypy does not complain\r\n\r\n**Actual Behavior**\r\n\r\nmypy reports \"error: Overloaded function signatures 2 and 3 overlap with incompatible return types [misc]\"\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.0.1\r\n- Mypy command-line flags: none\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.9\r\n\r\n","author":{"url":"https://github.com/henzef","@type":"Person","name":"henzef"},"datePublished":"2023-02-23T17:35:52Z","url":"https://github.com/python/mypy/issues/14770"}
| 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:b5e77fc4-5c1e-4538-9f58-3dc588b1bbab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F78:115983:3E9126:541DE2:6B002AB0 |
| html-safe-nonce | 40b12b6fe2b1eb328099329dd19416edf87c121039d96ee40cbc1f959d649cb2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Rjc4OjExNTk4MzozRTkxMjY6NTQxREUyOjZCMDAyQUIwIiwidmlzaXRvcl9pZCI6IjIwMzkxMjcyMzQxNDQzODE2MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ee114b5455eacca89b917a846c7571bdd0244c8770db19565da0418e0f40508c |
| hovercard-subject-tag | issue:1597267373 |
| 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/14770/issue_layout |
| twitter:image | https://opengraph.githubassets.com/543348475def6b2eaebfc78fe3db89fbb9efef55b9a268be60df24c0898feec6/python/mypy/issues/14770 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/543348475def6b2eaebfc78fe3db89fbb9efef55b9a268be60df24c0898feec6/python/mypy/issues/14770 |
| og:image:alt | Bug Report In the minimal example below, I get an unexpected "Overloaded function signatures overlap with incompatible return types" error from mypy. The example is taken from a general "wait for a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | henzef |
| 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