Title: "Signature of X incompatible with supertype Y" message could be more specific when return types differ · Issue #3818 · python/mypy · GitHub
Open Graph Title: "Signature of X incompatible with supertype Y" message could be more specific when return types differ · Issue #3818 · python/mypy
X Title: "Signature of X incompatible with supertype Y" message could be more specific when return types differ · Issue #3818 · python/mypy
Description: When investigating a (non-)issue in #3805, I ended up slightly more confused than I could have been due to the error messages I was seeing. When I run mypy against: from typing import Mapping, Iterable, Tuple, Optional class MyDict(Mappi...
Open Graph Description: When investigating a (non-)issue in #3805, I ended up slightly more confused than I could have been due to the error messages I was seeing. When I run mypy against: from typing import Mapping, Iter...
X Description: When investigating a (non-)issue in #3805, I ended up slightly more confused than I could have been due to the error messages I was seeing. When I run mypy against: from typing import Mapping, Iter...
Opengraph URL: https://github.com/python/mypy/issues/3818
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Signature of X incompatible with supertype Y\" message could be more specific when return types differ","articleBody":"When investigating a (non-)issue in #3805, I ended up slightly more confused than I could have been due to the error messages I was seeing. When I run mypy against:\r\n\r\n```py\r\nfrom typing import Mapping, Iterable, Tuple, Optional\r\n\r\n\r\nclass MyDict(Mapping):\r\n\r\n def items(self, irrelevant_arg: str = \"foo\") -> Iterable[Tuple[str, str]]: ...\r\n```\r\n\r\nI get:\r\n\r\n```\r\ntest.pyi:6: error: Signature of \"items\" incompatible with supertype \"Mapping\"\r\n```\r\n\r\nAs `Mapping.items()` doesn't take any arguments, my initial assumption was that the issue here was the argument. _However_, the issue is actually the return type; mypy is totally happy with:\r\n\r\n```py\r\n def items(self, irrelevant_arg: str = \"foo\") -> AbstractSet[Tuple[str, str]]: ...\r\n```\r\n\r\nand if the function hadn't had any arguments:\r\n\r\n```py\r\n def items(self) -> Iterable[Tuple[str, str]]: ...\r\n```\r\n\r\nthen mypy would actually have told me this:\r\n\r\n```\r\ntest.pyi:6: error: Return type of \"items\" incompatible with supertype \"Mapping\"\r\n```\r\n\r\nLooking at https://github.com/python/mypy/blob/master/mypy/checker.py#L1108-L1145, I _think_ that the return type checking could move out an `if`-statement and potentially affect the error output in both the same-args and different-number-of-args cases.","author":{"url":"https://github.com/OddBloke","@type":"Person","name":"OddBloke"},"datePublished":"2017-08-09T15:21:11Z","url":"https://github.com/python/mypy/issues/3818"}
| 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:1a924502-dfca-6033-3c41-ea215db76b6c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE74:2E9DBB:1884C88:2122157:6AFFF6B1 |
| html-safe-nonce | 2b27aa177e27475d7da702555ffd6ca2cdc180a90da0e859ee9c4706ed77a39c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTc0OjJFOURCQjoxODg0Qzg4OjIxMjIxNTc6NkFGRkY2QjEiLCJ2aXNpdG9yX2lkIjoiNDI2MDg4OTE1MDM2Nzk4NzM3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 042d02172a83e51bf9ea03177d344e68f39538c8d8f8d5c4bcaa28520a98651b |
| hovercard-subject-tag | issue:249067716 |
| 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/3818/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b891d851dcaa11bed3a44e1e981edad95b9af5a5f0f27b43fe98145ecde2a24b/python/mypy/issues/3818 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b891d851dcaa11bed3a44e1e981edad95b9af5a5f0f27b43fe98145ecde2a24b/python/mypy/issues/3818 |
| og:image:alt | When investigating a (non-)issue in #3805, I ended up slightly more confused than I could have been due to the error messages I was seeing. When I run mypy against: from typing import Mapping, Iter... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | OddBloke |
| 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