Title: The generic type of an inner function cannot be made to match the generic type of an enclosing function · Issue #8696 · python/mypy · GitHub
Open Graph Title: The generic type of an inner function cannot be made to match the generic type of an enclosing function · Issue #8696 · python/mypy
X Title: The generic type of an inner function cannot be made to match the generic type of an enclosing function · Issue #8696 · python/mypy
Description: With the following example: from typing import Callable, Generic, Type, TypeVar XType = TypeVar('XType', bound=int) class C(Generic[XType]): def f(self, x_init: XType) -> XType: return x_init def combinator(c_cls: Type[C[XType]]) -> Call...
Open Graph Description: With the following example: from typing import Callable, Generic, Type, TypeVar XType = TypeVar('XType', bound=int) class C(Generic[XType]): def f(self, x_init: XType) -> XType: return x_init def c...
X Description: With the following example: from typing import Callable, Generic, Type, TypeVar XType = TypeVar('XType', bound=int) class C(Generic[XType]): def f(self, x_init: XType) -> XType: return x...
Opengraph URL: https://github.com/python/mypy/issues/8696
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The generic type of an inner function cannot be made to match the generic type of an enclosing function","articleBody":"With the following example:\r\n\r\n```python\r\nfrom typing import Callable, Generic, Type, TypeVar\r\n\r\nXType = TypeVar('XType', bound=int)\r\n\r\n\r\nclass C(Generic[XType]):\r\n def f(self, x_init: XType) -> XType:\r\n return x_init\r\n\r\n\r\ndef combinator(c_cls: Type[C[XType]]) -> Callable[[C[XType], XType], XType]:\r\n old_f = c_cls.f\r\n\r\n def new_f(c: C[XType], x_init: XType) -> XType:\r\n return old_f(c, x_init)\r\n\r\n return new_f\r\n```\r\n\r\n\r\nMyPy 0.910 says:\r\n```\r\na.py:15: error: Incompatible return value type (got \"XType\", expected \"XType\")\r\na.py:15: error: Argument 1 has incompatible type \"C[XType]\"; expected \"C[XType]\"\r\na.py:15: error: Argument 2 has incompatible type \"XType\"; expected \"XType\"\r\n```","author":{"url":"https://github.com/NeilGirdhar","@type":"Person","name":"NeilGirdhar"},"datePublished":"2020-04-19T07:51:31Z","url":"https://github.com/python/mypy/issues/8696"}
| 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:2374930d-ef2b-83fc-70c8-2ffcc09c2e5d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E92:34D604:10E55E5:161B569:6B000636 |
| html-safe-nonce | f4cc63808a969d09cfc80de8aae22a7fa9f76f1dc711676e6ce1a6bd7c866ba7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTkyOjM0RDYwNDoxMEU1NUU1OjE2MUI1Njk6NkIwMDA2MzYiLCJ2aXNpdG9yX2lkIjoiNDQ2NjA4MzMyMTc2MzMzMzY4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 388679c588961bde06caced55c222307dd157735ef9b82329d0cc694bb0b6668 |
| hovercard-subject-tag | issue:602649872 |
| 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/8696/issue_layout |
| twitter:image | https://opengraph.githubassets.com/77de25e83adeed9fd0848ed8526d60dbd720b24a870ba8c27565c113b5fedbe8/python/mypy/issues/8696 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/77de25e83adeed9fd0848ed8526d60dbd720b24a870ba8c27565c113b5fedbe8/python/mypy/issues/8696 |
| og:image:alt | With the following example: from typing import Callable, Generic, Type, TypeVar XType = TypeVar('XType', bound=int) class C(Generic[XType]): def f(self, x_init: XType) -> XType: return x_init def c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NeilGirdhar |
| 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