Title: `typing.Annotated[int, ...]` is subclassable · Issue #96771 · python/cpython · GitHub
Open Graph Title: `typing.Annotated[int, ...]` is subclassable · Issue #96771 · python/cpython
X Title: `typing.Annotated[int, ...]` is subclassable · Issue #96771 · python/cpython
Description: You can subclass Annotated[int, "meta"]: >>> import typing >>> class Some(typing.Annotated[int, 'meta']): ... ... >>> Some.__mro__ (
Open Graph Description: You can subclass Annotated[int, "meta"]: >>> import typing >>> class Some(typing.Annotated[int, 'meta']): ... ... >>> Some.__mro__ (
X Description: You can subclass Annotated[int, "meta"]: >>> import typing >>> class Some(typing.Annotated[int, 'meta']): ... ... >>> Some.__mro__ (<class '__mai...
Opengraph URL: https://github.com/python/cpython/issues/96771
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`typing.Annotated[int, ...]` is subclassable","articleBody":"You can subclass `Annotated[int, \"meta\"]`:\r\n\r\n```python\r\n\u003e\u003e\u003e import typing\r\n\u003e\u003e\u003e class Some(typing.Annotated[int, 'meta']): ...\r\n... \r\n\u003e\u003e\u003e Some.__mro__\r\n(\u003cclass '__main__.Some'\u003e, \u003cclass 'int'\u003e, \u003cclass 'object'\u003e)\r\n```\r\n\r\nBut, here are a couple of problems:\r\n1. All metadata is lost: so, no reason to use `Annotated` in the first place\r\n2. https://peps.python.org/pep-0593/ never mentions this use-case\r\n3. We assume that `Annotated` cannot be subclassed: https://github.com/python/cpython/blame/53a54b781d1f05f2d0b40ce88b3da92d5d23e9d2/Lib/test/test_typing.py#L6562-L6565 here\r\n\r\nI think that `Annotated` should not be subclasses and this is a bug.\r\nThe PR is incoming :)\r\n\r\nI found this while working on https://github.com/python/cpython/issues/96769","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2022-09-12T10:48:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/96771/cpython/issues/96771"}
| 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:5e60e8ae-67df-aaa0-7f3a-b258f49d9382 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB4C:311995:12736D:180431:696AD658 |
| html-safe-nonce | 687f1ba8d94bde25981ff329663e01047bf05c14cf1899b133492e3181967c19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjRDOjMxMTk5NToxMjczNkQ6MTgwNDMxOjY5NkFENjU4IiwidmlzaXRvcl9pZCI6IjYwODMyODgyNDg0MjA1ODcwOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25ffc53b4d863d0c27e2175ad59b031ffbab438aea064890dd0ba36a5b513abb |
| hovercard-subject-tag | issue:1369671028 |
| 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/96771/issue_layout |
| twitter:image | https://opengraph.githubassets.com/217b2402a2793af7a9674f04d1fa28fe2fe5996cd7d5a99750f5ee5f5eb6dec1/python/cpython/issues/96771 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/217b2402a2793af7a9674f04d1fa28fe2fe5996cd7d5a99750f5ee5f5eb6dec1/python/cpython/issues/96771 |
| og:image:alt | You can subclass Annotated[int, "meta"]: >>> import typing >>> class Some(typing.Annotated[int, 'meta']): ... ... >>> Some.__mro__ ( |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| 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 | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width