Title: False positive when calling a method from a subclass · Issue #15097 · python/mypy · GitHub
Open Graph Title: False positive when calling a method from a subclass · Issue #15097 · python/mypy
X Title: False positive when calling a method from a subclass · Issue #15097 · python/mypy
Description: Bug Report I encounter a false positive using mypy when a Generic class indirectly calls a method defined in its GrandParent. To Reproduce from typing import Generic, TypeVar T = TypeVar("T") class Grandparent(Generic[T]): def say_hello(...
Open Graph Description: Bug Report I encounter a false positive using mypy when a Generic class indirectly calls a method defined in its GrandParent. To Reproduce from typing import Generic, TypeVar T = TypeVar("T") class...
X Description: Bug Report I encounter a false positive using mypy when a Generic class indirectly calls a method defined in its GrandParent. To Reproduce from typing import Generic, TypeVar T = TypeVar("T&qu...
Opengraph URL: https://github.com/python/mypy/issues/15097
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False positive when calling a method from a subclass","articleBody":"**Bug Report**\r\n\r\nI encounter a false positive using mypy when a Generic class indirectly calls a method defined in its GrandParent. \r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Generic, TypeVar\r\n\r\nT = TypeVar(\"T\")\r\n\r\n\r\nclass Grandparent(Generic[T]):\r\n def say_hello(self) -> str:\r\n return \"Hello\"\r\n\r\n\r\nclass Parent(Grandparent[T]):\r\n pass\r\n\r\n\r\nclass Child(Parent[T]):\r\n def say_hello(self) -> str:\r\n return Parent.say_hello(self)\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nNo error when running mypy.\r\n\r\n**Actual Behavior**\r\n\r\nI get this error:\r\n`error: Argument 1 to \"say_hello\" of \"Grandparent\" has incompatible type \"Child[T]\"; expected \"Grandparent[T]\" [arg-type]`\r\n\r\nRemoving the Generic types, calling `Grandparent.say_hello(self)` from the child, redefining the method in the Parent fixes the error.\r\n\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.2.0\r\n- Python version used: 3.10.0\r\n","author":{"url":"https://github.com/Aegdesil","@type":"Person","name":"Aegdesil"},"datePublished":"2023-04-21T12:39:59Z","url":"https://github.com/python/mypy/issues/15097"}
| 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:2d575e90-2465-76a1-4992-198f8a734806 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DABA:15E5F9:1945353:221B383:6AFFF982 |
| html-safe-nonce | ed095d3193b1939637c3f6259e45ebdb69a25e0840e46d30684c753334f479ee |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUJBOjE1RTVGOToxOTQ1MzUzOjIyMUIzODM6NkFGRkY5ODIiLCJ2aXNpdG9yX2lkIjoiNjM5MzM0NDI4MTU3NDA5NjY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8d30c348a23fdce19e383d2c19d0db88900e0bf0a0cf3ff4faa0ba32dd2cb8a1 |
| hovercard-subject-tag | issue:1678459260 |
| 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/15097/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ce050fd1782aede2ff5f757e21087ae31836ff998ebb4dcaa576914f3466c0ff/python/mypy/issues/15097 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ce050fd1782aede2ff5f757e21087ae31836ff998ebb4dcaa576914f3466c0ff/python/mypy/issues/15097 |
| og:image:alt | Bug Report I encounter a false positive using mypy when a Generic class indirectly calls a method defined in its GrandParent. To Reproduce from typing import Generic, TypeVar T = TypeVar("T") class... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Aegdesil |
| 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