Title: Improve type inference for recursive protocols · Issue #3829 · python/mypy · GitHub
Open Graph Title: Improve type inference for recursive protocols · Issue #3829 · python/mypy
X Title: Improve type inference for recursive protocols · Issue #3829 · python/mypy
Description: Consider this example: class P(Protocol[T_co]): def meth(self) -> P[T_co]: ... class C(Generic[T]): def meth(self) -> C[T]: ... def fun(arg: P[T]) -> T: ... x: C[int] reveal_type(f(x)) # I think this should be 'int' But currently the inf...
Open Graph Description: Consider this example: class P(Protocol[T_co]): def meth(self) -> P[T_co]: ... class C(Generic[T]): def meth(self) -> C[T]: ... def fun(arg: P[T]) -> T: ... x: C[int] reveal_type(f(x)) # I think th...
X Description: Consider this example: class P(Protocol[T_co]): def meth(self) -> P[T_co]: ... class C(Generic[T]): def meth(self) -> C[T]: ... def fun(arg: P[T]) -> T: ... x: C[int] reveal_type(f(x)) # I...
Opengraph URL: https://github.com/python/mypy/issues/3829
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve type inference for recursive protocols","articleBody":"Consider this example:\r\n```python\r\nclass P(Protocol[T_co]):\r\n def meth(self) -> P[T_co]: ...\r\n\r\nclass C(Generic[T]):\r\n def meth(self) -> C[T]: ...\r\n\r\ndef fun(arg: P[T]) -> T: ...\r\nx: C[int]\r\nreveal_type(f(x)) # I think this should be 'int'\r\n```\r\nBut currently the inferred type is ``UninhabitedType``, since we don't find any constraints for ``T`` due to a purely structural inference cycle. Unfortunately, it looks like this doesn't have simple solutions.\r\n\r\nThis is a follow-up for #3132 ","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2017-08-15T12:23:22Z","url":"https://github.com/python/mypy/issues/3829"}
| 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:b8db69df-808e-5865-e332-6662d340b0d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82AE:3EE8F1:BDE62E:F72351:6AFFE55B |
| html-safe-nonce | abaf0d5f26803d36f0a4b005dc59af674f5036c627424dbf62917713e75e44ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkFFOjNFRThGMTpCREU2MkU6RjcyMzUxOjZBRkZFNTVCIiwidmlzaXRvcl9pZCI6Ijg0NzAwOTg5Njc1MTI3MzcxMTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7ddc5657c96c3ffb40b49728e5ea2c140a1e663e6c35bd4785866904aa88bb2c |
| hovercard-subject-tag | issue:250299475 |
| 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/3829/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cdc6148f125f5285eb156596a2ed5b512f01c7feb3d02740661048cc514c500d/python/mypy/issues/3829 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cdc6148f125f5285eb156596a2ed5b512f01c7feb3d02740661048cc514c500d/python/mypy/issues/3829 |
| og:image:alt | Consider this example: class P(Protocol[T_co]): def meth(self) -> P[T_co]: ... class C(Generic[T]): def meth(self) -> C[T]: ... def fun(arg: P[T]) -> T: ... x: C[int] reveal_type(f(x)) # I think th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilevkivskyi |
| 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