Title: Inconsistent return type when calling overloaded function with Any argument · Issue #3662 · python/mypy · GitHub
Open Graph Title: Inconsistent return type when calling overloaded function with Any argument · Issue #3662 · python/mypy
X Title: Inconsistent return type when calling overloaded function with Any argument · Issue #3662 · python/mypy
Description: The results of type checking the following fragment are unexpected: from typing import Any, overload, Union @overload def f(x: int) -> int: ... @overload def f(x: Union[int, float]) -> float: ... def f(x): pass @overload def g(x: int) ->...
Open Graph Description: The results of type checking the following fragment are unexpected: from typing import Any, overload, Union @overload def f(x: int) -> int: ... @overload def f(x: Union[int, float]) -> float: ... d...
X Description: The results of type checking the following fragment are unexpected: from typing import Any, overload, Union @overload def f(x: int) -> int: ... @overload def f(x: Union[int, float]) -> float:...
Opengraph URL: https://github.com/python/mypy/issues/3662
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent return type when calling overloaded function with Any argument","articleBody":"The results of type checking the following fragment are unexpected:\r\n\r\n```py\r\nfrom typing import Any, overload, Union\r\n\r\n@overload\r\ndef f(x: int) -> int: ...\r\n@overload\r\ndef f(x: Union[int, float]) -> float: ...\r\ndef f(x): pass\r\n\r\n@overload\r\ndef g(x: int) -> int: ...\r\n@overload\r\ndef g(x: float) -> float: ...\r\ndef g(x): pass\r\n\r\na: Any\r\nreveal_type(f(a)) # Any \u003c--- okay\r\nreveal_type(g(a)) # int \u003c--- unexpected\r\n```\r\n\r\nThe correct result would arguably be `Any` for both of the calls. `Union[int, float]` should be equivalent to just `float`.\r\n\r\nThis seems to interact with the result type of `os.path.join` in Python 2 mode with #3300.","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2017-07-05T16:51:06Z","url":"https://github.com/python/mypy/issues/3662"}
| 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:43271425-fe06-1a13-f077-9dd011db2a4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 800C:120A77:1CE9816:272B228:6B000CA3 |
| html-safe-nonce | 4f17964ac82bf621a803c2fc63f40b396512370b1d2772484ff85b761ad1c4ec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDBDOjEyMEE3NzoxQ0U5ODE2OjI3MkIyMjg6NkIwMDBDQTMiLCJ2aXNpdG9yX2lkIjoiNjk1Mjc0MjkwNzk1MDQwMjcyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fa31eaccab1042275b9a5879eaa2992d6cfd10cdc516567a427fc94fb4853d6e |
| hovercard-subject-tag | issue:240712398 |
| 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/3662/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56b85cca0b1ae6f7d4544cb020194c3c9a9a519a9285671380d7ee8be11ebbde/python/mypy/issues/3662 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56b85cca0b1ae6f7d4544cb020194c3c9a9a519a9285671380d7ee8be11ebbde/python/mypy/issues/3662 |
| og:image:alt | The results of type checking the following fragment are unexpected: from typing import Any, overload, Union @overload def f(x: int) -> int: ... @overload def f(x: Union[int, float]) -> float: ... d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| 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