Title: Wrong overload resolution with alias to Any · Issue #15630 · python/mypy · GitHub
Open Graph Title: Wrong overload resolution with alias to Any · Issue #15630 · python/mypy
X Title: Wrong overload resolution with alias to Any · Issue #15630 · python/mypy
Description: Bug Report Overload resolution appears to pick the first matching overload if the argument type is an alias to Any. It should consider all overloads. This works correctly when using Any directly (without an alias). This came up in python...
Open Graph Description: Bug Report Overload resolution appears to pick the first matching overload if the argument type is an alias to Any. It should consider all overloads. This works correctly when using Any directly (w...
X Description: Bug Report Overload resolution appears to pick the first matching overload if the argument type is an alias to Any. It should consider all overloads. This works correctly when using Any directly (w...
Opengraph URL: https://github.com/python/mypy/issues/15630
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong overload resolution with alias to Any","articleBody":"**Bug Report**\r\n\r\nOverload resolution appears to pick the first matching overload if the argument type is an alias to Any. It should consider all overloads. This works correctly when using Any directly (without an alias). This came up in https://github.com/python/typeshed/issues/10405.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Any, Union, overload\r\n\r\n@overload\r\ndef my_origin(x: type) -> type: ...\r\n\r\n@overload\r\ndef my_origin(x: Any) -> Any: ...\r\n\r\ndef my_origin(x: Any) -> Any:\r\n return x\r\n\r\ndef call_any(spec: Any) -> bool:\r\n return my_origin(spec) is Union\r\n\r\nTypeSpec = Any\r\n\r\ndef call_alias(spec: TypeSpec) -> bool:\r\n return my_origin(spec) is Union\r\n```\r\nhttps://mypy-play.net/?mypy=latest&python=3.11&flags=strict&gist=26e08b7414caad553cd0e9549928da11\r\n\r\n**Expected Behavior**\r\n\r\nBoth `call_any` and `call_alias` should type check without errors, since they are the same thing.\r\n\r\n**Actual Behavior**\r\n\r\n`call_alias` produces an error in strict mode:\r\n```\r\nproj/overload.py:18: error: Non-overlapping identity check (left operand type: \"type\", right operand type: \"\u003ctyping special form>\") [comparison-overlap]\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.4.1\r\n- Mypy command-line flags: --strict\r\n- Python version used: 3.10.6\r\n","author":{"url":"https://github.com/eltoder","@type":"Person","name":"eltoder"},"datePublished":"2023-07-09T17:22:30Z","url":"https://github.com/python/mypy/issues/15630"}
| 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:12fafd14-1a5f-2e47-2fef-f55e509e9be9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8794:B5253:11ED62E:17862E4:6B000BB1 |
| html-safe-nonce | de4867458dac75f173e351898496b70bf7fa8841f6f7cbe77cd98a32068108ea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Nzk0OkI1MjUzOjExRUQ2MkU6MTc4NjJFNDo2QjAwMEJCMSIsInZpc2l0b3JfaWQiOiI3MTgzMTI4ODYyMTI4MDgxODQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 65f675342e9307ecf3acea12b64c027bd2669f5ec7f826259309bae7f3025058 |
| hovercard-subject-tag | issue:1795489439 |
| 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/15630/issue_layout |
| twitter:image | https://opengraph.githubassets.com/76917e00cb05aad84f91b426d8a84f30229c457ebc14d30dc7812d1c64cfdb9c/python/mypy/issues/15630 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/76917e00cb05aad84f91b426d8a84f30229c457ebc14d30dc7812d1c64cfdb9c/python/mypy/issues/15630 |
| og:image:alt | Bug Report Overload resolution appears to pick the first matching overload if the argument type is an alias to Any. It should consider all overloads. This works correctly when using Any directly (w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eltoder |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width