Title: Tracking issue for overloads · Issue #5119 · python/mypy · GitHub
Open Graph Title: Tracking issue for overloads · Issue #5119 · python/mypy
X Title: Tracking issue for overloads · Issue #5119 · python/mypy
Description: This is an issue summarizing all remaining TODOs for the overloads overhaul. Done Add support for detecting partially-overlapping arities. For example, disallow f(A, A) -> int and f(*A) -> str. This will likely require modifications to i...
Open Graph Description: This is an issue summarizing all remaining TODOs for the overloads overhaul. Done Add support for detecting partially-overlapping arities. For example, disallow f(A, A) -> int and f(*A) -> str. Thi...
X Description: This is an issue summarizing all remaining TODOs for the overloads overhaul. Done Add support for detecting partially-overlapping arities. For example, disallow f(A, A) -> int and f(*A) -> st...
Opengraph URL: https://github.com/python/mypy/issues/5119
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tracking issue for overloads","articleBody":"This is an issue summarizing all remaining TODOs for the overloads overhaul.\r\n\r\n## Done\r\n\r\n- [x] Add support for detecting partially-overlapping arities. \r\n\r\n For example, disallow `f(A, A) -> int` and `f(*A) -> str`. This will likely require modifications to `is_callable_compatible` (or require implementing a new, similar method).\r\n\r\n- [x] Improve union math semantics. Related issues:\r\n\r\n - [Support basic union math for overloaded functions](https://github.com/python/mypy/issues/4576)\r\n - [One more bug with union math logic](https://github.com/python/mypy/issues/5243)\r\n - [Wrong overload resolution with Any union item in argument](https://github.com/python/mypy/issues/5249) (?)\r\n\r\n- [x] Update docs to clarify what the new overload semantics are. Related issues:\r\n\r\n - [Docs for function overloading are made more complex by using __getitem__ as example](https://github.com/python/mypy/issues/4579)\r\n\r\n- [x] Improving how overload implementations are checked. Related issues:\r\n\r\n - [Errors when using overloaded functions and type variables](https://github.com/python/mypy/issues/4619)\r\n\r\n- [x] Add full support for partially-overlapping types.\r\n\r\n For example, disallow `f(Union[A, B]) -> int` and `f(Union[B, C]) -> str`. We currently support detect partially-overlapping unions and tuples on just the top-level.\r\n\r\n Related issues:\r\n\r\n - [Allow overloading based on TypedDict structure](https://github.com/python/mypy/issues/3618)\r\n - [Overloaded function signatures 1 and 2 overlap with incompatible return types](https://github.com/python/mypy/issues/4020)\r\n - [Allow overloads to be distinguished by contained type of a generic](https://github.com/python/mypy/issues/4159)\r\n - [spurious \"Need type annotation\" error with overloads](https://github.com/python/mypy/issues/4227)\r\n\r\n Sub-todos:\r\n\r\n - [x] If all arguments in the first overload are partially overlapping with the second, report an error (even if the first return type is narrower).\r\n\r\n We should also probably have a custom error message, since this is technically safe when the first return type is narrower. This should also probably wait until we have more robust support for partially-overlapping types.\r\n\r\n **Edit**: We decided it wasn't worth complicating the code to handle this TODO.\r\n\r\n## In-progress\r\n\r\n- [x] Add union math for operators. See https://github.com/python/mypy/issues/2128.\r\n\r\n- [ ] Error messages need a usability overhaul. Related open issues:\r\n\r\n - [Give better error messages when calling overloaded function with invalid types](https://github.com/python/mypy/issues/672)\r\n - [Ordering matters for @overload](https://github.com/python/mypy/issues/1270) (error message could be improved)\r\n - [More specific overlapping overload errors](https://github.com/python/mypy/issues/3819)\r\n - [Handling de-facto positional-only arguments with overloads](https://github.com/python/mypy/issues/5235)\r\n\r\n## Remaining todos:\r\n\r\n- [ ] Overload subtypes could be enhanced to use the new union math algorithms in some way. Related open issues:\r\n\r\n - [Type inference problems with unions, overloads and map](https://github.com/python/mypy/issues/390)\r\n - [Overloaded function as a subtype of function with union types args/return](https://github.com/python/mypy/issues/495)\r\n\r\n- [ ] Improve test coverage:\r\n\r\n Sub-TODOs:\r\n\r\n - [ ] Add test cases for situations where the overload definitions have a type error (that may or may not have been type-ignored).\r\n\r\n- [ ] Update PEP 484/submit a new mini-PEP or something.\r\n\r\n## Remaining todos; deprioritized\r\n\r\n- [ ] Re-think how overloads, operator overloading, and overload subtyping interacts. Related open issues:\r\n\r\n - [Make operator overloading overlapping checks more lenient](https://github.com/python/mypy/issues/1264)\r\n - [Ordering matters for @overload](https://github.com/python/mypy/issues/1270) (one of the error messages seems like a bug)\r\n - [Overloading function issues (incompatible with supertype). ](https://github.com/python/mypy/issues/3750)\r\n - [Signatures of overloaded operators are incompatible with super type](https://github.com/python/mypy/issues/4985)\r\n\r\n Sub-TODOs:\r\n\r\n - [x] Update code for operator methods to take advantages of the overload refactorings. \r\n\r\n For example, I think operator methods currently might be ignoring generics when checking for overlaps (though it's unclear if this is actually an issue in real-life code). This mostly boils down to using `is_callable_compatible` in clever ways within `is_unsafe_overlapping_operator_signatures` and adding more tests.\r\n\r\n- [ ] Enhance binder to understand how overloads and NoReturn interact. Related issues:\r\n\r\n - [Narrow types using overload information](https://github.com/python/mypy/issues/4063)\r\n\r\n- [ ] General refactoring and cleanup:\r\n\r\n - [ ] Adjust the semantic analysis phase so we use the same binding for a typevar across all overload alternatives. \r\n\r\n This would let us remove `merge_typevars_in_callables_by_name`. Implementing this would probably require refactoring `TypeVarScope`?\r\n\r\n- [ ] Improving how overloads and decorators interact. Related issues:\r\n\r\n - [Running mypy with --disallow-untyped-decorators reports an error for overloaded decorators](https://github.com/python/mypy/issues/4191)\r\n\r\n## Issues that need triaging\r\n\r\n- [ ] [Optional strict checking of overloads](https://github.com/python/mypy/issues/4333)\r\n- [ ] [Refactor operator method access and protocol checks to use checkmember.py](https://github.com/python/mypy/issues/5136)","author":{"url":"https://github.com/Michael0x2a","@type":"Person","name":"Michael0x2a"},"datePublished":"2018-05-29T07:13:19Z","url":"https://github.com/python/mypy/issues/5119"}
| 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:55912969-60f0-0051-9753-2bd73184e86d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB1E:BACA4:2E48B2F:3D47A86:6B0028A3 |
| html-safe-nonce | 7969f090b739c33c3f0e6e78fb278209969aa72902d417944d491b945f37c8fa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjFFOkJBQ0E0OjJFNDhCMkY6M0Q0N0E4Njo2QjAwMjhBMyIsInZpc2l0b3JfaWQiOiIyOTgyNTI0MzA4MzEzNjE0NDk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bd3dc95145fc76fbe912257888a7863cd7026772a7af156222e3039553d08c95 |
| hovercard-subject-tag | issue:327195443 |
| 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/5119/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe4d6b47aad26e058e37579ff9d4106b80a4d352f9c2b9c09fc974638d8b324f/python/mypy/issues/5119 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe4d6b47aad26e058e37579ff9d4106b80a4d352f9c2b9c09fc974638d8b324f/python/mypy/issues/5119 |
| og:image:alt | This is an issue summarizing all remaining TODOs for the overloads overhaul. Done Add support for detecting partially-overlapping arities. For example, disallow f(A, A) -> int and f(*A) -> str. Thi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Michael0x2a |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width