Title: Incorrect incompatible override report with self type + overload + TypeVar with constraints · Issue #14866 · python/mypy · GitHub
Open Graph Title: Incorrect incompatible override report with self type + overload + TypeVar with constraints · Issue #14866 · python/mypy
X Title: Incorrect incompatible override report with self type + overload + TypeVar with constraints · Issue #14866 · python/mypy
Description: Similar to #14002; came up in python/typeshed#9084. from typing import TypeVar, Generic, overload T = TypeVar("T", str, int) class Base(Generic[T]): @overload def method(self, s: T) -> T: ... @overload def method(self: Base[str], s: byte...
Open Graph Description: Similar to #14002; came up in python/typeshed#9084. from typing import TypeVar, Generic, overload T = TypeVar("T", str, int) class Base(Generic[T]): @overload def method(self, s: T) -> T: ... @over...
X Description: Similar to #14002; came up in python/typeshed#9084. from typing import TypeVar, Generic, overload T = TypeVar("T", str, int) class Base(Generic[T]): @overload def method(self, s: T) ->...
Opengraph URL: https://github.com/python/mypy/issues/14866
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect incompatible override report with self type + overload + TypeVar with constraints","articleBody":"Similar to #14002; came up in python/typeshed#9084.\r\n\r\n```python\r\nfrom typing import TypeVar, Generic, overload\r\n\r\nT = TypeVar(\"T\", str, int)\r\n\r\nclass Base(Generic[T]):\r\n @overload\r\n def method(self, s: T) -> T: ...\r\n @overload\r\n def method(self: Base[str], s: bytes) -> str: ...\r\n def method(self, s: object): ...\r\n\r\nclass Child(Base[int]):\r\n def method(self, s: int) -> int:\r\n raise NotImplementedError\r\n```\r\n(https://mypy-play.net/?mypy=latest&python=3.10&gist=da356a97851f7b7649d208e1359a6de4)\r\n\r\nwith mypy 1.1.1 produces:\r\n\r\n```\r\n/Users/jelle/bin/inerhit.py:13: error: Signature of \"method\" incompatible with supertype \"Base\" [override]\r\n/Users/jelle/bin/inerhit.py:13: note: Superclass:\r\n/Users/jelle/bin/inerhit.py:13: note: @overload\r\n/Users/jelle/bin/inerhit.py:13: note: def method(self, s: int) -> int\r\n/Users/jelle/bin/inerhit.py:13: note: @overload\r\n/Users/jelle/bin/inerhit.py:13: note: def method(self, s: bytes) -> str\r\n/Users/jelle/bin/inerhit.py:13: note: Subclass:\r\n/Users/jelle/bin/inerhit.py:13: note: def method(self, s: int) -> int\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nThere should be no errors. The second overload is not applicable to a `Base[int]`, so it should be fine that the subclass lacks it.","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2023-03-10T04:16:12Z","url":"https://github.com/python/mypy/issues/14866"}
| 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:328d0961-f92c-3991-4033-abc2dc3058f4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84E2:3E1398:5C282E:7B6EA2:6B003334 |
| html-safe-nonce | efe9f30ce3919b9b7dda5766d564ac67feace81e09c418e08066a74710f64034 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEUyOjNFMTM5ODo1QzI4MkU6N0I2RUEyOjZCMDAzMzM0IiwidmlzaXRvcl9pZCI6IjQ3MzI5MzE5NDYyNjEyNjMxNTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d87e9319c80db242da8a67b0aa0a585ba0ac436dc8226649b95f887c753cbfb5 |
| hovercard-subject-tag | issue:1618334567 |
| 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/14866/issue_layout |
| twitter:image | https://opengraph.githubassets.com/319d25866d70d1a27ebf47bea0e652b1e959ef050710d61e73ed2b5c80260cda/python/mypy/issues/14866 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/319d25866d70d1a27ebf47bea0e652b1e959ef050710d61e73ed2b5c80260cda/python/mypy/issues/14866 |
| og:image:alt | Similar to #14002; came up in python/typeshed#9084. from typing import TypeVar, Generic, overload T = TypeVar("T", str, int) class Base(Generic[T]): @overload def method(self, s: T) -> T: ... @over... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width