Title: Problems using class type variable in class methods · Issue #3645 · python/mypy · GitHub
Open Graph Title: Problems using class type variable in class methods · Issue #3645 · python/mypy
X Title: Problems using class type variable in class methods · Issue #3645 · python/mypy
Description: Follow up from a discussion on gitter: from typing import * T = TypeVar('T') class Factory(Generic[T]): @classmethod def instance(cls) -> 'Factory[T]': return cls() def produce(self) -> T: raise NotImplementedError() @classmethod def get...
Open Graph Description: Follow up from a discussion on gitter: from typing import * T = TypeVar('T') class Factory(Generic[T]): @classmethod def instance(cls) -> 'Factory[T]': return cls() def produce(self) -> T: raise No...
X Description: Follow up from a discussion on gitter: from typing import * T = TypeVar('T') class Factory(Generic[T]): @classmethod def instance(cls) -> 'Factory[T]': return cls() def produce(s...
Opengraph URL: https://github.com/python/mypy/issues/3645
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Problems using class type variable in class methods","articleBody":"Follow up from a discussion on gitter:\r\n\r\n```python\r\nfrom typing import *\r\n\r\n\r\nT = TypeVar('T')\r\nclass Factory(Generic[T]):\r\n @classmethod\r\n def instance(cls) -> 'Factory[T]':\r\n return cls()\r\n\r\n def produce(self) -> T:\r\n raise NotImplementedError()\r\n\r\n @classmethod\r\n def get(cls) -> T:\r\n return cls.instance().produce()\r\n\r\n\r\nclass HelloWorldFactory(Factory[str]):\r\n def produce(self) -> str:\r\n return 'Hello World'\r\n\r\n\r\n# factory.py:25: error: Incompatible return value type (got \"T\", expected \"str\")\r\ndef error_with_mypy() -> str:\r\n return HelloWorldFactory.get()\r\n```\r\n\r\n@ilevkivskyi mentioned this should not error and that this code is valid. I don't have the necessary context to understand how to classify this issue.","author":{"url":"https://github.com/LiraNuna","@type":"Person","name":"LiraNuna"},"datePublished":"2017-07-01T07:19:49Z","url":"https://github.com/python/mypy/issues/3645"}
| 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:24d7ddaa-0315-b667-df81-a29e459b014d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2D4:1BAA33:1AFED47:23D6CB2:6B002C54 |
| html-safe-nonce | e601edd33f594f8128f8f30d9bb5ec9b0dab13aa3f6b86d6b1b8521fcebc7f07 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkQ0OjFCQUEzMzoxQUZFRDQ3OjIzRDZDQjI6NkIwMDJDNTQiLCJ2aXNpdG9yX2lkIjoiNjc3MjMyMDQ0MTQ3MTA4NTY1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0d25b689a7722c5224eb7e9b19c6f354512183e1dca705c85b866a54285dd5b6 |
| hovercard-subject-tag | issue:239933397 |
| 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/3645/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cdd89496729b12f5a3eff831f0d4ecd33311857abbcfd48a70768b48f5c16ffd/python/mypy/issues/3645 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cdd89496729b12f5a3eff831f0d4ecd33311857abbcfd48a70768b48f5c16ffd/python/mypy/issues/3645 |
| og:image:alt | Follow up from a discussion on gitter: from typing import * T = TypeVar('T') class Factory(Generic[T]): @classmethod def instance(cls) -> 'Factory[T]': return cls() def produce(self) -> T: raise No... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LiraNuna |
| 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