Title: Bug or new behavior of generics parameterization? · Issue #98852 · python/cpython · GitHub
Open Graph Title: Bug or new behavior of generics parameterization? · Issue #98852 · python/cpython
X Title: Bug or new behavior of generics parameterization? · Issue #98852 · python/cpython
Description: from typing import TypeVar, Generic, Callable T = TypeVar("T") P = TypeVar("P") class Test(Generic[T]): ... S = Callable[[Test], P] def test(arg: S[T]): ... On python3.11 i can't run this code. Code falls on an attempt to parameterize S ...
Open Graph Description: from typing import TypeVar, Generic, Callable T = TypeVar("T") P = TypeVar("P") class Test(Generic[T]): ... S = Callable[[Test], P] def test(arg: S[T]): ... On python3.11 i can't run this code. Cod...
X Description: from typing import TypeVar, Generic, Callable T = TypeVar("T") P = TypeVar("P") class Test(Generic[T]): ... S = Callable[[Test], P] def test(arg: S[T]): ... On python3.11 i can&...
Opengraph URL: https://github.com/python/cpython/issues/98852
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug or new behavior of generics parameterization?","articleBody":"```python3\r\nfrom typing import TypeVar, Generic, Callable\r\n\r\n\r\nT = TypeVar(\"T\")\r\nP = TypeVar(\"P\")\r\n\r\nclass Test(Generic[T]): ...\r\n\r\n\r\nS = Callable[[Test], P]\r\n\r\ndef test(arg: S[T]): ...\r\n\r\n```\r\n\r\nOn python3.11 i can't run this code. Code falls on an attempt to parameterize `S`\r\nTraceback:\r\n\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\KIRILL-1\\PycharmProjects\\dataclass_factory\\exp.py\", line 12, in \u003cmodule\u003e \r\n def test(arg: S[T]): ... \r\n ~^^^ \r\n File \"C:\\Users\\KIRILL-1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\typing.py\", line 360, in inner \r\n return cached(*args, **kwds)\r\n ^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\KIRILL-1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\typing.py\", line 1391, in __getitem__\r\n new_args = self._determine_new_args(args)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\KIRILL-1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\typing.py\", line 1440, in _determine_new_args\r\n subargs.append(new_arg_by_param[x])\r\n ~~~~~~~~~~~~~~~~^^^\r\nKeyError: ~T\r\n```\r\nHow i understand, in 3.11, an attempt is being made to parameterize `Test` in `S`, but in 3.10 - not\r\nIs it new behavior or a bug?\r\n\n\n\u003c!-- gh-pr-number: gh-98920 --\u003e\n* PR: gh-98920\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-98952 --\u003e\n* PR: gh-98952\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-98969 --\u003e\n* PR: gh-98969\n\u003c!-- /gh-pr-number --\u003e\n","author":{"url":"https://github.com/Eclips4","@type":"Person","name":"Eclips4"},"datePublished":"2022-10-29T16:39:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/98852/cpython/issues/98852"}
| 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:8ce9821e-d9b5-c4d8-c035-4c12d9eb2c75 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 99AE:392F59:16B530:2053A0:6969FE5E |
| html-safe-nonce | 579c10e5f907f23bb5d322972c87d77d1adcd100ad3c4781c9663dab98d4f9bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUFFOjM5MkY1OToxNkI1MzA6MjA1M0EwOjY5NjlGRTVFIiwidmlzaXRvcl9pZCI6IjczMjg3ODExNTc1ODAxNDA0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ad1340b46e6d1f5e4de223307d022f79291d4e140370291cf8bcdb891dd99e85 |
| hovercard-subject-tag | issue:1428350452 |
| 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/cpython/98852/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5273a8bcf1120e4879202c363eb47ad75f7315ffc53cb5136f4638c87b19e9c1/python/cpython/issues/98852 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5273a8bcf1120e4879202c363eb47ad75f7315ffc53cb5136f4638c87b19e9c1/python/cpython/issues/98852 |
| og:image:alt | from typing import TypeVar, Generic, Callable T = TypeVar("T") P = TypeVar("P") class Test(Generic[T]): ... S = Callable[[Test], P] def test(arg: S[T]): ... On python3.11 i can't run this code. Cod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Eclips4 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width