Title: Incorrect format passed to `__annotate__` function · Issue #125507 · python/cpython · GitHub
Open Graph Title: Incorrect format passed to `__annotate__` function · Issue #125507 · python/cpython
X Title: Incorrect format passed to `__annotate__` function · Issue #125507 · python/cpython
Description: Bug report Consider this example: class My: def __annotate__(format): assert format == 2, format return {} import annotationlib annotationlib.get_annotations(My, format=2) This will fail with: Traceback (most recent call last): File "/Us...
Open Graph Description: Bug report Consider this example: class My: def __annotate__(format): assert format == 2, format return {} import annotationlib annotationlib.get_annotations(My, format=2) This will fail with: Trac...
X Description: Bug report Consider this example: class My: def __annotate__(format): assert format == 2, format return {} import annotationlib annotationlib.get_annotations(My, format=2) This will fail with: Trac...
Opengraph URL: https://github.com/python/cpython/issues/125507
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect format passed to `__annotate__` function","articleBody":"# Bug report\n\nConsider this example:\n\n```python\nclass My:\n def __annotate__(format):\n assert format == 2, format\n return {}\n\nimport annotationlib\nannotationlib.get_annotations(My, format=2)\n```\n\nThis will fail with:\n\n```\nTraceback (most recent call last):\n File \"/Users/sobolev/Desktop/cpython2/ex.py\", line 7, in \u003cmodule\u003e\n annotationlib.get_annotations(My, format=2)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^\n File \"/Users/sobolev/Desktop/cpython2/Lib/annotationlib.py\", line 688, in get_annotations\n return dict(_get_dunder_annotations(obj))\n ~~~~~~~~~~~~~~~~~~~~~~~^^^^^\n File \"/Users/sobolev/Desktop/cpython2/Lib/annotationlib.py\", line 817, in _get_dunder_annotations\n ann = _BASE_GET_ANNOTATIONS(obj)\n File \"/Users/sobolev/Desktop/cpython2/ex.py\", line 3, in __annotate__\n assert format == 2, format\n ^^^^^^^^^^^\nAssertionError: 1\n```\n\nI think that we should still pass the format in `_BASE_GET_ANNOTATIONS`.\n\nI will try to fix this, since this affects my other PR: https://github.com/python/cpython/pull/122262\n\nCC @JelleZijlstra \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-125534\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2024-10-15T09:44:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/125507/cpython/issues/125507"}
| 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:8c0cbd15-f61d-9c70-6e84-7fe56be0b3fe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D3E:2DCEFE:14D321:1BEDAE:696B3070 |
| html-safe-nonce | a7c01ad23935bb555e35000e1e2a4b83e553f670e1217c666bee785087a601ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDNFOjJEQ0VGRToxNEQzMjE6MUJFREFFOjY5NkIzMDcwIiwidmlzaXRvcl9pZCI6IjM0MDk3NzYyNzMyMjk4MjAwMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4008f0f66dc53692823c0522711c8734ca802e6f47aa789670ea2cfb3c040312 |
| hovercard-subject-tag | issue:2588218527 |
| 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/125507/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3bd875bd71fe0ef795786c126c064bd02100f3f3261d8026553fd304b895e4b1/python/cpython/issues/125507 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3bd875bd71fe0ef795786c126c064bd02100f3f3261d8026553fd304b895e4b1/python/cpython/issues/125507 |
| og:image:alt | Bug report Consider this example: class My: def __annotate__(format): assert format == 2, format return {} import annotationlib annotationlib.get_annotations(My, format=2) This will fail with: Trac... |
| 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 | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width