René's URL Explorer Experiment


Title: `typing.get_type_hints()` raises on invalid types only if they're wrapped in a ForwardRef · Issue #133959 · python/cpython · GitHub

Open Graph Title: `typing.get_type_hints()` raises on invalid types only if they're wrapped in a ForwardRef · Issue #133959 · python/cpython

X Title: `typing.get_type_hints()` raises on invalid types only if they're wrapped in a ForwardRef · Issue #133959 · python/cpython

Description: >>> import typing >>> def f(x: typing.ClassVar[int]): pass ... >>> typing.get_type_hints(f) {'x': typing.ClassVar[int]} >>> def f(x: "typing.ClassVar[int]"): pass ... >>> typing.get_type_hints(f) Traceback (most recent call last): File "...

Open Graph Description: >>> import typing >>> def f(x: typing.ClassVar[int]): pass ... >>> typing.get_type_hints(f) {'x': typing.ClassVar[int]} >>> def f(x: "typing.ClassVar[int]"): pass ... >>> typing.get_type_hints(f) T...

X Description: >>> import typing >>> def f(x: typing.ClassVar[int]): pass ... >>> typing.get_type_hints(f) {'x': typing.ClassVar[int]} >>> def f(x: "typing.ClassVa...

Opengraph URL: https://github.com/python/cpython/issues/133959

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`typing.get_type_hints()` raises on invalid types only if they're wrapped in a ForwardRef","articleBody":"```pytb\n>>> import typing\n>>> def f(x: typing.ClassVar[int]): pass\n... \n>>> typing.get_type_hints(f)\n{'x': typing.ClassVar[int]}\n>>> def f(x: \"typing.ClassVar[int]\"): pass\n... \n>>> typing.get_type_hints(f)\nTraceback (most recent call last):\n  File \"\u003cpython-input-4>\", line 1, in \u003cmodule>\n    typing.get_type_hints(f)\n    ~~~~~~~~~~~~~~~~~~~~~^^^\n  File \"/Users/jelle/py/cpython/Lib/typing.py\", line 2390, in get_type_hints\n    hints[name] = _eval_type(value, globalns, localns, type_params, format=format, owner=obj)\n                  ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Users/jelle/py/cpython/Lib/typing.py\", line 448, in _eval_type\n    return evaluate_forward_ref(t, globals=globalns, locals=localns,\n                                type_params=type_params, owner=owner,\n                                _recursive_guard=recursive_guard, format=format)\n  File \"/Users/jelle/py/cpython/Lib/typing.py\", line 993, in evaluate_forward_ref\n    type_ = _type_check(\n        value,\n    ...\u003c2 lines>...\n        allow_special_forms=forward_ref.__forward_is_class__,\n    )\n  File \"/Users/jelle/py/cpython/Lib/typing.py\", line 204, in _type_check\n    raise TypeError(f\"{arg} is not valid as type argument\")\nTypeError: typing.ClassVar[int] is not valid as type argument\n```\n\n(On main but also reproduced on 3.13.)\n\nThis seems inconsistent and I don't think it's helpful for users. We should either raise in both cases or neither. I prefer to not raise in either case, because it's less disruptive for callers (they already have to deal with `ClassVar` etc. potentially appearing in annotations), and provides more information.","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2025-05-13T02:01:38Z","url":"https://github.com/python/cpython/issues/133959"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fe4f6ae3-5ea4-3523-6d1a-00982448e702
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9FD4:3E7030:346C4A:46BCA7:6B0028D2
html-safe-nonce1e0e759d730611e5dc6acaa67b698d2b92977ef40361acb0dcce7941f451e753
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkQ0OjNFNzAzMDozNDZDNEE6NDZCQ0E3OjZCMDAyOEQyIiwidmlzaXRvcl9pZCI6IjU3MTEwMzk4OTgxNDQ3NDU2ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac82e556e389406f9eea2c33c3b888ccb5394bae9ed398e2b7b5694972c4f5cf8f
hovercard-subject-tagissue:3058558899
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/133959/issue_layout
twitter:imagehttps://opengraph.githubassets.com/10796bd2b62b326116c8abfd117eb64f184128c51328e0945c61dfb9cf65cad0/python/cpython/issues/133959
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/10796bd2b62b326116c8abfd117eb64f184128c51328e0945c61dfb9cf65cad0/python/cpython/issues/133959
og:image:alt>>> import typing >>> def f(x: typing.ClassVar[int]): pass ... >>> typing.get_type_hints(f) {'x': typing.ClassVar[int]} >>> def f(x: "typing.ClassVar[int]"): pass ... >>> typing.get_type_hints(f) T...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJelleZijlstra
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release44c658b24abf00491fb7ae5f56d42c9f38cbeab2
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/133959#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F133959
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F133959
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/133959
Reloadhttps://github.com/python/cpython/issues/133959
Reloadhttps://github.com/python/cpython/issues/133959
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/133959
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/133959
#133961https://github.com/python/cpython/pull/133961
typing.get_type_hints() raises on invalid types only if they're wrapped in a ForwardRefhttps://github.com/python/cpython/issues/133959#top
#133961https://github.com/python/cpython/pull/133961
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-typinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-typing%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on May 13, 2025https://github.com/python/cpython/issues/133959#issue-3058558899
JelleZijlstrahttps://github.com/JelleZijlstra
topic-typinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-typing%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
on May 13, 2025https://github.com/python/cpython/issues/133959#event-17626861866
JelleZijlstrahttps://github.com/JelleZijlstra
on May 13, 2025https://github.com/python/cpython/issues/133959#event-17627553193
pythongh-133960: Improve typing.evaluate_forward_refhttps://github.com/JelleZijlstra/cpython/commit/b1f050e99fb259d423d1b8bbafff26675388bdad
pythongh-133960https://github.com/python/cpython/issues/133960
https://docs.github.com/articles/closing-issues-via-commit-messages
b1f050ehttps://github.com/JelleZijlstra/cpython/commit/b1f050e99fb259d423d1b8bbafff26675388bdad
picnixzhttps://github.com/picnixz
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on May 15, 2025https://github.com/python/cpython/issues/133959#event-17672326880
JelleZijlstrahttps://github.com/JelleZijlstra
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#133961https://github.com/python/cpython/pull/133961
on May 25, 2025https://github.com/python/cpython/issues/133959#event-17805005313
JelleZijlstrahttps://github.com/JelleZijlstra
on May 25, 2025https://github.com/python/cpython/issues/133959#event-17805005320
gh-133960: Improve typing.evaluate_forward_ref (#133961)https://github.com/python/cpython/commit/57fef27cfc2bdfc1e3a65ef8c8a760198d15b14d
gh-133960https://github.com/python/cpython/issues/133960
#133961https://github.com/python/cpython/pull/133961
https://docs.github.com/articles/closing-issues-via-commit-messages
57fef27https://github.com/python/cpython/commit/57fef27cfc2bdfc1e3a65ef8c8a760198d15b14d
miss-islingtonhttps://github.com/miss-islington
on May 25, 2025https://github.com/python/cpython/issues/133959#event-17805005721
pythongh-133960: Improve typing.evaluate_forward_ref (pythonGH-133961)https://github.com/miss-islington/cpython/commit/f64c059c3b046889feb5e1310c7340154524595e
pythongh-133960https://github.com/python/cpython/issues/133960
pythonGH-133961https://github.com/python/cpython/pull/133961
https://docs.github.com/articles/closing-issues-via-commit-messages
f64c059https://github.com/miss-islington/cpython/commit/f64c059c3b046889feb5e1310c7340154524595e
JelleZijlstrahttps://github.com/JelleZijlstra
on May 25, 2025https://github.com/python/cpython/issues/133959#event-17805064790
[3.14] gh-133960: Improve typing.evaluate_forward_ref (GH-133961) (#1…https://github.com/python/cpython/commit/9c6d2dbe26e30114773bf55147d36960cb89e519
gh-133960https://github.com/python/cpython/issues/133960
GH-133961https://github.com/python/cpython/pull/133961
#1…https://github.com/python/cpython/pull/134663
https://docs.github.com/articles/closing-issues-via-commit-messages
9c6d2dbhttps://github.com/python/cpython/commit/9c6d2dbe26e30114773bf55147d36960cb89e519
Pranjal095https://github.com/Pranjal095
on Jul 12, 2025https://github.com/python/cpython/issues/133959#event-18600175941
pythongh-133960: Improve typing.evaluate_forward_ref (python#133961)https://github.com/Pranjal095/cpython/commit/fe50df53dfb2e38029bdcf98c9103e819c516135
pythongh-133960https://github.com/python/cpython/issues/133960
python#133961https://github.com/python/cpython/pull/133961
https://docs.github.com/articles/closing-issues-via-commit-messages
fe50df5https://github.com/Pranjal095/cpython/commit/fe50df53dfb2e38029bdcf98c9103e819c516135
taegyunkimhttps://github.com/taegyunkim
on Aug 4, 2025https://github.com/python/cpython/issues/133959#event-18976826240
pythongh-133960: Improve typing.evaluate_forward_ref (python#133961)https://github.com/taegyunkim/cpython/commit/a9a2ca9efafcaf346c4fd7c75f84eed57e3a6208
pythongh-133960https://github.com/python/cpython/issues/133960
python#133961https://github.com/python/cpython/pull/133961
https://docs.github.com/articles/closing-issues-via-commit-messages
a9a2ca9https://github.com/taegyunkim/cpython/commit/a9a2ca9efafcaf346c4fd7c75f84eed57e3a6208
gostak-ddhttps://github.com/gostak-dd
on Jun 2, 2026https://github.com/python/cpython/issues/133959#event-26248246336
pythongh-133960: Improve typing.evaluate_forward_ref (python#133961)https://github.com/gostak-dd/cpython/commit/39d149038a0469ce32d5b0ee458e6534cba282b6
pythongh-133960https://github.com/python/cpython/issues/133960
python#133961https://github.com/python/cpython/pull/133961
https://docs.github.com/articles/closing-issues-via-commit-messages
39d1490https://github.com/gostak-dd/cpython/commit/39d149038a0469ce32d5b0ee458e6534cba282b6
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/133959
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/133959
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-typinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-typing%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.