Title: Generic Self Type classmethods behave incorrectly on instances · Issue #3630 · python/mypy · GitHub
Open Graph Title: Generic Self Type classmethods behave incorrectly on instances · Issue #3630 · python/mypy
X Title: Generic Self Type classmethods behave incorrectly on instances · Issue #3630 · python/mypy
Description: Repro: from typing import TypeVar, Tuple, Type T = TypeVar('T', bound='Friend') class Friend: other = None # type: Friend @classmethod def make(cls: Type[T]) -> T: return cls() class SuperFriend(Friend): pass reveal_type(SuperFriend.make...
Open Graph Description: Repro: from typing import TypeVar, Tuple, Type T = TypeVar('T', bound='Friend') class Friend: other = None # type: Friend @classmethod def make(cls: Type[T]) -> T: return cls() class SuperFriend(Fr...
X Description: Repro: from typing import TypeVar, Tuple, Type T = TypeVar('T', bound='Friend') class Friend: other = None # type: Friend @classmethod def make(cls: Type[T]) -> T: return cls() c...
Opengraph URL: https://github.com/python/mypy/issues/3630
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic Self Type classmethods behave incorrectly on instances","articleBody":"Repro:\r\n\r\n```python\r\nfrom typing import TypeVar, Tuple, Type\r\n\r\nT = TypeVar('T', bound='Friend')\r\n\r\nclass Friend:\r\n other = None # type: Friend\r\n\r\n @classmethod\r\n def make(cls: Type[T]) -> T:\r\n return cls()\r\n\r\nclass SuperFriend(Friend):\r\n pass\r\n\r\nreveal_type(SuperFriend.make()) # Revealed type is 'test_generic_self.SuperFriend*'\r\nreveal_type(SuperFriend().make()) # Revealed type is '\u003cnothing>'\r\n```\r\n\r\nBoth invocations should return `test_generic_self.SuperFriend*`.","author":{"url":"https://github.com/rowillia","@type":"Person","name":"rowillia"},"datePublished":"2017-06-29T06:09:48Z","url":"https://github.com/python/mypy/issues/3630"}
| 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:962bfe81-bdd3-b3d0-fdea-fd452c6268b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB50:2FFC0A:4F2D77:6EF414:6B007358 |
| html-safe-nonce | 510d4621ebeb676725890f58ea6a501750d984e8603724c912d14e92ba0ac70a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjUwOjJGRkMwQTo0RjJENzc6NkVGNDE0OjZCMDA3MzU4IiwidmlzaXRvcl9pZCI6IjgzMjMxMzU4MzM4Njc1ODAyNDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f7eed676dcb0292290b193be3d78c5cb7a6b6d43e9ad6bbc8ecb94cbf665554d |
| hovercard-subject-tag | issue:239374960 |
| 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/3630/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e0c4eb9b61b6c8766de506a3fca0c8ac1bf2a0c2cc194c79a9b2064824cab18/python/mypy/issues/3630 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e0c4eb9b61b6c8766de506a3fca0c8ac1bf2a0c2cc194c79a9b2064824cab18/python/mypy/issues/3630 |
| og:image:alt | Repro: from typing import TypeVar, Tuple, Type T = TypeVar('T', bound='Friend') class Friend: other = None # type: Friend @classmethod def make(cls: Type[T]) -> T: return cls() class SuperFriend(Fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rowillia |
| hostname | github.com |
| expected-hostname | github.com |
| None | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| 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 | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width