Title: Add reference implementation of PEP 718 · Issue #21337 · python/mypy · GitHub
Open Graph Title: Add reference implementation of PEP 718 · Issue #21337 · python/mypy
X Title: Add reference implementation of PEP 718 · Issue #21337 · python/mypy
Description: I think this is very much needed PEP, and using mypy for reference implementation is a good idea because mypy actually already (mostly) supports this under the hood. The only non-trivial question is whether we should allow type applicati...
Open Graph Description: I think this is very much needed PEP, and using mypy for reference implementation is a good idea because mypy actually already (mostly) supports this under the hood. The only non-trivial question i...
X Description: I think this is very much needed PEP, and using mypy for reference implementation is a good idea because mypy actually already (mostly) supports this under the hood. The only non-trivial question i...
Opengraph URL: https://github.com/python/mypy/issues/21337
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add reference implementation of PEP 718","articleBody":"I think this is very much needed PEP, and using mypy for reference implementation is a good idea because mypy actually already (mostly) supports this under the hood.\n\nThe only non-trivial question is whether we should allow type applications only to references that are statically known to refer to a function, or do we want to support type application to an arbitrary expression that happen to have a callable-like type inferred? For example:\n```python\nT = TypeVar(\"T\")\n\nclass Callbacks(TypedDict):\n regular: Callable[[int], int]\n generic: Callable[[T], T]\n\ndef test(cb: Callbacks) -> None:\n cb[\"generic\"][int] # \u003c- should we support this?\n```\nIf we only want to support static references, then implementation is trivial, essentially:\n* Make [this error](https://github.com/python/mypy/blob/a850b6612abcf04f6c7079173a63a821d77915ab/mypy/checkexpr.py#L4948-L4949) conditional on Python version \u003c3.15 and file being not a stub.\n* Update [this helper](https://github.com/python/mypy/blob/a850b6612abcf04f6c7079173a63a821d77915ab/mypy/semanal.py#L8235) to accept a `Decorator`.\n\nHowever, if we want to support arbitrary expressions, it should be quite easy as well. Luckily, all the necessary infrastructure was added for `TypeForm` PEP support. We can use `TypeCheckerAsSemanticAnalyzer` adapter to re-interpret arbitrary expression as type during type checking.\n\ncc @JukkaL @Gobot1234 @PabloRuizCuevas","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2026-04-26T18:35:05Z","url":"https://github.com/python/mypy/issues/21337"}
| 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:ffe1c5e5-8399-d081-9b9c-836e9f3f27e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFC0:27AD12:331550:44EF3F:6B002806 |
| html-safe-nonce | 9ac8fd4145c7bf262aa863afbbf23107e3629f442f87e5ea883593f4d0bbad6b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkMwOjI3QUQxMjozMzE1NTA6NDRFRjNGOjZCMDAyODA2IiwidmlzaXRvcl9pZCI6IjQzMTI1Nzk2MTQzNTEzMDQ3MTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c18981d4b4836671768a8b875b41f20fa732033e5edb5ab081735fd7f34cc277 |
| hovercard-subject-tag | issue:4331651871 |
| 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/21337/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3071676f9aee948b69554f2908b8f55a4efa6773194e12c88ab0419db55b48cb/python/mypy/issues/21337 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3071676f9aee948b69554f2908b8f55a4efa6773194e12c88ab0419db55b48cb/python/mypy/issues/21337 |
| og:image:alt | I think this is very much needed PEP, and using mypy for reference implementation is a good idea because mypy actually already (mostly) supports this under the hood. The only non-trivial question i... |
| 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 | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width