Title: Simplify `typing.evaluate_forward_ref` · Issue #133960 · python/cpython · GitHub
Open Graph Title: Simplify `typing.evaluate_forward_ref` · Issue #133960 · python/cpython
X Title: Simplify `typing.evaluate_forward_ref` · Issue #133960 · python/cpython
Description: Bug report In PEP-749 I added typing.evaluate_forward_ref to replace the private typing.ForwardRef._evaluate, which is being used by some external users. The current documentation claims these differences from annotationlib.ForwardRef.ev...
Open Graph Description: Bug report In PEP-749 I added typing.evaluate_forward_ref to replace the private typing.ForwardRef._evaluate, which is being used by some external users. The current documentation claims these diff...
X Description: Bug report In PEP-749 I added typing.evaluate_forward_ref to replace the private typing.ForwardRef._evaluate, which is being used by some external users. The current documentation claims these diff...
Opengraph URL: https://github.com/python/cpython/issues/133960
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Simplify `typing.evaluate_forward_ref`","articleBody":"# Bug report\n\nIn PEP-749 I added `typing.evaluate_forward_ref` to replace the private `typing.ForwardRef._evaluate`, which is being used by some external users.\n\nThe current [documentation](https://docs.python.org/3.14/library/typing.html#typing.evaluate_forward_ref) claims these differences from `annotationlib.ForwardRef.evaluate`:\n\n1. Recursively evaluates forward references nested within the type hint.\n2. Raises TypeError when it encounters certain objects that are not valid type hints.\n3. Replaces type hints that evaluate to None with types.NoneType.\n4. Supports the FORWARDREF and STRING formats.\n\n(1) is useful and fits well with the typing module; annotationlib can't do this because it requires introspecting into typing-specific objects. (2) I feel is not useful (compare #133959): the type check is not particularly thorough, and it's generally better for callers to allow more objects through that callers can handle on their own terms. (3) is sort of harmless but not particularly useful. (4) is not true any more since I also added support for these formats to `ForwardRef.evaluate`.\n\nSo I'd like to drop differences 2 through 4, leaving the function focused on recursively evaluating nested ForwardRefs.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-133961\n* gh-134663\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2025-05-13T02:09:32Z","url":"https://github.com/python/cpython/issues/133960"}
| 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:29c39405-8115-2ba4-52ec-4938688514b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A274:2C3D4F:391FAF:4CD8DD:6B0028D1 |
| html-safe-nonce | b67a803cd7c693311ccabb54e2ce7fb35f3107b93c7739197ed8340ad4975f4a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjc0OjJDM0Q0RjozOTFGQUY6NENEOEREOjZCMDAyOEQxIiwidmlzaXRvcl9pZCI6IjE2MjE4NDQ1ODgzNzUzMjA3ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3565a6ef7603719c6f6fad7434d1c0bbdde3bdb8c255206d61d3f519b4bde82d |
| hovercard-subject-tag | issue:3058567389 |
| 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/133960/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbe5d623940f11496028a089e4718506c470dc1a982080de2138bc24329bc041/python/cpython/issues/133960 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbe5d623940f11496028a089e4718506c470dc1a982080de2138bc24329bc041/python/cpython/issues/133960 |
| og:image:alt | Bug report In PEP-749 I added typing.evaluate_forward_ref to replace the private typing.ForwardRef._evaluate, which is being used by some external users. The current documentation claims these diff... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width