Title: Signatures of overloaded operators are incompatible with super type · Issue #4985 · python/mypy · GitHub
Open Graph Title: Signatures of overloaded operators are incompatible with super type · Issue #4985 · python/mypy
X Title: Signatures of overloaded operators are incompatible with super type · Issue #4985 · python/mypy
Description: I've noticed this problem, very similar to #3262 , except with overloaded operators. Originally, #3262 made it so that code like this: from typing import overload class A: def f(self, x : 'A') -> 'A': ... class B(A): @overload def f(self...
Open Graph Description: I've noticed this problem, very similar to #3262 , except with overloaded operators. Originally, #3262 made it so that code like this: from typing import overload class A: def f(self, x : 'A') -> '...
X Description: I've noticed this problem, very similar to #3262 , except with overloaded operators. Originally, #3262 made it so that code like this: from typing import overload class A: def f(self, x : '...
Opengraph URL: https://github.com/python/mypy/issues/4985
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Signatures of overloaded operators are incompatible with super type","articleBody":"I've noticed this problem, very similar to #3262 , except with overloaded operators.\r\n\r\nOriginally, #3262 made it so that code like this:\r\n```\r\nfrom typing import overload\r\n\r\nclass A:\r\n def f(self, x : 'A') -> 'A': ...\r\n\r\nclass B(A):\r\n @overload\r\n def f(self, x : 'A') -> 'A': ...\r\n @overload\r\n def f(self, x : 'B') -> 'B' : ...\r\n```\r\n\r\nWouldn't typecheck. \r\n\r\n#3263 appears to have fixed this. Unfortunately, while this works for normal method signatures, it doesn't appear to work for overloaded operators. So the very similar code:\r\n\r\n```\r\nfrom typing import overload\r\n\r\nclass A:\r\n def __add__(self, x : 'A') -> 'A': ...\r\n\r\nclass B(A):\r\n @overload\r\n def __add__(self, x : 'A') -> 'A': ...\r\n @overload\r\n def __add__(self, x : 'B') -> 'B' : ...\r\n```\r\n\r\nStill fails to typecheck, with the error message:\r\n```\r\ntest.pyi:7: error: Signature of \"__add__\" incompatible with supertype \"A\"\r\n```\r\n\r\nI can't think of any reason why this should be a problem with operators, although maybe someone else can explain.\r\n\r\nI'm on Python 3.6.3 and MyPy 0.600+dev (master branch from git)\r\n","author":{"url":"https://github.com/HazardousPeach","@type":"Person","name":"HazardousPeach"},"datePublished":"2018-04-28T20:10:58Z","url":"https://github.com/python/mypy/issues/4985"}
| 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:a501474c-c684-a0c3-d13d-062f77e83d1a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9AE:3A7693:18C194D:2148749:6AFFF159 |
| html-safe-nonce | bde429d6739265cfde79df5f67687b44c35667269b55f17ca8d6fbda9076586b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUFFOjNBNzY5MzoxOEMxOTREOjIxNDg3NDk6NkFGRkYxNTkiLCJ2aXNpdG9yX2lkIjoiNjEyOTg5NDU5MjEzODQ0MTA0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c46e33eb04280b0c57f6062d5323968ccb338060d58033843581663b32ebbf02 |
| hovercard-subject-tag | issue:318665181 |
| 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/4985/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c55d20b30cef4e3d4486e7d599676e036fa6957d40453672232d4d704c261443/python/mypy/issues/4985 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c55d20b30cef4e3d4486e7d599676e036fa6957d40453672232d4d704c261443/python/mypy/issues/4985 |
| og:image:alt | I've noticed this problem, very similar to #3262 , except with overloaded operators. Originally, #3262 made it so that code like this: from typing import overload class A: def f(self, x : 'A') -> '... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | HazardousPeach |
| 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