René's URL Explorer Experiment


Title: contextlib.contextmanager allows `Iterator[T]` -- should probably be `Generator[T, None, None]`? · Issue #2772 · python/typeshed · GitHub

Open Graph Title: contextlib.contextmanager allows `Iterator[T]` -- should probably be `Generator[T, None, None]`? · Issue #2772 · python/typeshed

X Title: contextlib.contextmanager allows `Iterator[T]` -- should probably be `Generator[T, None, None]`? · Issue #2772 · python/typeshed

Description: For instance, this script passes mypy: import contextlib from typing import Iterator @contextlib.contextmanager def f() -> Iterator[int]: return iter([1]) with f(): pass with f(): raise TypeError('wat') but fails at runtime (and not in t...

Open Graph Description: For instance, this script passes mypy: import contextlib from typing import Iterator @contextlib.contextmanager def f() -> Iterator[int]: return iter([1]) with f(): pass with f(): raise TypeError('...

X Description: For instance, this script passes mypy: import contextlib from typing import Iterator @contextlib.contextmanager def f() -> Iterator[int]: return iter([1]) with f(): pass with f(): raise TypeErro...

Opengraph URL: https://github.com/python/typeshed/issues/2772

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"contextlib.contextmanager allows `Iterator[T]` -- should probably be `Generator[T, None, None]`?","articleBody":"For instance, this script passes mypy:\r\n\r\n```python\r\nimport contextlib\r\nfrom typing import Iterator\r\n\r\n@contextlib.contextmanager\r\ndef f() -> Iterator[int]:\r\n    return iter([1])\r\n\r\n\r\nwith f():\r\n    pass\r\n\r\n\r\nwith f():\r\n    raise TypeError('wat')\r\n```\r\n\r\nbut fails at runtime (and not in the expected way):\r\n\r\n```console\r\n$ python t.py \r\nTraceback (most recent call last):\r\n  File \"t.py\", line 14, in \u003cmodule>\r\n    raise TypeError('wat')\r\nTypeError: wat\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"t.py\", line 14, in \u003cmodule>\r\n    raise TypeError('wat')\r\n  File \"/usr/lib/python3.6/contextlib.py\", line 99, in __exit__\r\n    self.gen.throw(type, value, traceback)\r\nAttributeError: 'list_iterator' object has no attribute 'throw'\r\n```","author":{"url":"https://github.com/asottile","@type":"Person","name":"asottile"},"datePublished":"2019-01-30T00:06:39Z","url":"https://github.com/python/typeshed/issues/2772"}

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:09be3d50-30d7-7a4b-34dd-495eceaf80a3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD9D8:3F7946:1F144E3:2A3C087:6B001A1E
html-safe-noncea0f9b140ef4add67f5864d2cbf2a1bbccdc8f3c24ee79a62c35d2a8a27249371
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUQ4OjNGNzk0NjoxRjE0NEUzOjJBM0MwODc6NkIwMDFBMUUiLCJ2aXNpdG9yX2lkIjoiNTg0Nzc4ODExMzUwMTM2MjcxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf6c7d0c053f9c64fccbbc67d0ec01a4461373e0a66375dea1949b092d8cb1d6c
hovercard-subject-tagissue:404542703
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/typeshed/2772/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a20cef35efb18f66e8192e709b7df7085ca57f4561adfcddd266a16045f68f46/python/typeshed/issues/2772
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a20cef35efb18f66e8192e709b7df7085ca57f4561adfcddd266a16045f68f46/python/typeshed/issues/2772
og:image:altFor instance, this script passes mypy: import contextlib from typing import Iterator @contextlib.contextmanager def f() -> Iterator[int]: return iter([1]) with f(): pass with f(): raise TypeError('...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameasottile
hostnamegithub.com
expected-hostnamegithub.com
Nonea2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4
turbo-cache-controlno-preview
go-importgithub.com/python/typeshed git https://github.com/python/typeshed.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id31696383
octolytics-dimension-repository_nwopython/typeshed
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31696383
octolytics-dimension-repository_network_root_nwopython/typeshed
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
release70121d4e855ee0bb7b75cf15d061d91f8863c0f8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/2772#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F2772
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%2Ftypeshed%2Fissues%2F2772
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%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/2772
Reloadhttps://github.com/python/typeshed/issues/2772
Reloadhttps://github.com/python/typeshed/issues/2772
pythonhttps://github.com/python
typeshedhttps://github.com/python/typeshed
Codehttps://github.com/python/typeshed
Issues196 (196)https://github.com/python/typeshed/issues
Pull requests251 (251)https://github.com/python/typeshed/pulls
Actionshttps://github.com/python/typeshed/actions
Security and qualityhttps://github.com/python/typeshed/security
Insightshttps://github.com/python/typeshed/insights
https://github.com/python/typeshed
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/2772
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/2772
#12087https://github.com/python/typeshed/pull/12087
contextlib.contextmanager allows Iterator[T] -- should probably be Generator[T, None, None]?https://github.com/python/typeshed/issues/2772#top
#12087https://github.com/python/typeshed/pull/12087
status: deferredIssue or PR deferred until some precondition is fixedhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22status%3A%20deferred%22
stubs: false negativeType checkers do not report an error, but shouldhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20negative%22
https://github.com/asottile
asottilehttps://github.com/asottile
on Jan 30, 2019https://github.com/python/typeshed/issues/2772#issue-404542703
srittauhttps://github.com/srittau
size-smallhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22size-small%22
stubs: false negativeType checkers do not report an error, but shouldhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20negative%22
on Jan 30, 2019https://github.com/python/typeshed/issues/2772#event-2105827115
https://github.com/srittau
srittauhttps://github.com/srittau
on Jan 30, 2019https://github.com/python/typeshed/issues/2772#issuecomment-458854033
https://github.com/graingert
graingerthttps://github.com/graingert
on Jun 30, 2021https://github.com/python/typeshed/issues/2772#issuecomment-871438097
https://github.com/asottile
asottilehttps://github.com/asottile
on Mar 1, 2022https://github.com/python/typeshed/issues/2772#issuecomment-1055750534
https://github.com/HacKanCuBa
HacKanCuBahttps://github.com/HacKanCuBa
on Jun 2, 2022https://github.com/python/typeshed/issues/2772#issuecomment-1145185523
the docs suggesthttps://docs.python.org/3/library/typing.html#typing.Generator
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Jun 2, 2022https://github.com/python/typeshed/issues/2772#issuecomment-1145256763
the docs suggesthttps://docs.python.org/3/library/typing.html#typing.Generator
@asottilehttps://github.com/asottile
https://github.com/HacKanCuBa
HacKanCuBahttps://github.com/HacKanCuBa
on Jun 3, 2022https://github.com/python/typeshed/issues/2772#issuecomment-1146088832
the docs suggesthttps://docs.python.org/3/library/typing.html#typing.Generator
@asottilehttps://github.com/asottile
AlexWaygoodhttps://github.com/AlexWaygood
status: deferredIssue or PR deferred until some precondition is fixedhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22status%3A%20deferred%22
size-smallhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22size-small%22
on Nov 1, 2023https://github.com/python/typeshed/issues/2772#event-10835430519
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 1, 2023https://github.com/python/typeshed/issues/2772#issuecomment-1789425913
#7430 (comment)https://github.com/python/typeshed/pull/7430#issuecomment-1238711970
https://github.com/srittau
srittauhttps://github.com/srittau
on Feb 14, 2024https://github.com/python/typeshed/issues/2772#issuecomment-1943952146
#11422https://github.com/python/typeshed/issues/11422
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Feb 20, 2024https://github.com/python/typeshed/issues/2772#issuecomment-1953339863
#7430 (comment)https://github.com/python/typeshed/pull/7430#issuecomment-1238711970
#7430 (comment)https://github.com/python/typeshed/pull/7430#issuecomment-1080460175
Akulihttps://github.com/Akuli
status: deferredIssue or PR deferred until some precondition is fixedhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22status%3A%20deferred%22
status: deferredIssue or PR deferred until some precondition is fixedhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22status%3A%20deferred%22
on Jun 3, 2024https://github.com/python/typeshed/issues/2772#event-13023966001
https://github.com/max-muoto
max-muotohttps://github.com/max-muoto
on Jul 13, 2024https://github.com/python/typeshed/issues/2772#issuecomment-2227045093
#12334https://github.com/python/typeshed/pull/12334
SpecLadhttps://github.com/SpecLad
on Oct 30, 2024https://github.com/python/typeshed/issues/2772#event-15004597557
Fix return type annotations for functions used with @contextmanagerhttps://github.com/SpecLad/cvat/commit/48a69cf22e5296dd6ed0074e99521ad486e5696a
@contextmanagerhttps://github.com/contextmanager
48a69cfhttps://github.com/SpecLad/cvat/commit/48a69cf22e5296dd6ed0074e99521ad486e5696a
Fix return type annotations for functions used with @contextmanager (#…https://github.com/cvat-ai/cvat/commit/23e1e0a8539d75bc2367566d2a5138e12a29a64a
@contextmanagerhttps://github.com/contextmanager
#…https://github.com/cvat-ai/cvat/pull/8617
23e1e0ahttps://github.com/cvat-ai/cvat/commit/23e1e0a8539d75bc2367566d2a5138e12a29a64a
srittauhttps://github.com/srittau
completedhttps://github.com/python/typeshed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#12087https://github.com/python/typeshed/pull/12087
on Jan 23, 2026https://github.com/python/typeshed/issues/2772#event-22240059181
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/2772
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/2772
status: deferredIssue or PR deferred until some precondition is fixedhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22status%3A%20deferred%22
stubs: false negativeType checkers do not report an error, but shouldhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20negative%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.