René's URL Explorer Experiment


Title: No Generator is considered to be an instance of GeneratorType · Issue #5496 · python/typeshed · GitHub

Open Graph Title: No Generator is considered to be an instance of GeneratorType · Issue #5496 · python/typeshed

X Title: No Generator is considered to be an instance of GeneratorType · Issue #5496 · python/typeshed

Description: Bug Report types.GeneratorType is documented as "The type of generator-iterator objects, created by generator functions." Therefore I would expect that a value annotated using typing.Generator would be considered an instance of Generator...

Open Graph Description: Bug Report types.GeneratorType is documented as "The type of generator-iterator objects, created by generator functions." Therefore I would expect that a value annotated using typing.Generator woul...

X Description: Bug Report types.GeneratorType is documented as "The type of generator-iterator objects, created by generator functions." Therefore I would expect that a value annotated using typing.Gene...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"No Generator is considered to be an instance of GeneratorType","articleBody":"**Bug Report**\r\n\r\n`types.GeneratorType` is [documented as](https://docs.python.org/3/library/types.html#types.GeneratorType) \"The type of generator-iterator objects, created by generator functions.\" Therefore I would expect that a value annotated using `typing.Generator` would be considered an instance of `GeneratorType`. However, that is not the case.\r\n\r\nIt is possible that this issue originates in typeshed instead of mypy; I don't know whether mypy is drawing the wrong conclusions or is operating on flawed definitions. Even if the problem is in typeshed, perhaps mypy can output a more detailed error message, listing which method signatures it considers incompatible.\r\n\r\n**To Reproduce**\r\n\r\nRun mypy on the following code:\r\n\r\n```py\r\nfrom types import GeneratorType\r\nfrom typing import Any, Generator\r\n\r\ndef check(g: Generator[Any, Any, Any]) -> None:\r\n    if not isinstance(g, GeneratorType):\r\n        raise TypeError(\"Not a generator\")\r\n    print(\"It is a generator\")\r\n\r\ndef gen() -> Generator[int, None, None]:\r\n    yield 123\r\n\r\ncheck(gen())\r\n\r\ntry:\r\n    check(None)\r\nexcept TypeError:\r\n    print(\"Non-generator is rejected\")\r\nelse:\r\n    print(\"Non-generator is accepted\")\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nOnly `check(None)` should be flagged as an error.\r\n\r\n**Actual Behavior**\r\n\r\n```\r\n$ mypy generator_type.py \r\ngenerator_type.py:5: error: Subclass of \"Generator[Any, Any, Any]\" and \"GeneratorType\" cannot exist: would have incompatible method signatures  [unreachable]\r\ngenerator_type.py:7: error: Statement is unreachable  [unreachable]\r\ngenerator_type.py:15: error: Argument 1 to \"check\" has incompatible type \"None\"; expected \"Generator[Any, Any, Any]\"  [arg-type]\r\nFound 3 errors in 1 file (checked 1 source file)\r\n```\r\n\r\nThe first error (`isinstance`), reported on line 5, is the one I consider a bug.\r\nThe error reported on line 7 (`print`) is a consequence of the one on line 5.\r\nThe error reported on line 15 (`check(None)`) is an actual error.\r\n\r\nNote that the runtime behavior is as expected:\r\n```\r\n$ python generator_type.py \r\nIt is a generator\r\nNon-generator is rejected\r\n```\r\n\r\n**Your Environment**\r\n\r\nI'm using mypy 0.812 with Python 3.8.8 on openSUSE Linux.\r\n","author":{"url":"https://github.com/mthuurne","@type":"Person","name":"mthuurne"},"datePublished":"2021-05-18T19:55:38Z","url":"https://github.com/python/typeshed/issues/5496"}

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:50fa97f6-ddbc-889d-1d7a-168d09595844
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE0A0:3FDF0C:9E8C46:D3371B:6B0043A4
html-safe-nonce6c8cc603c895c6bf2a224042a2820bc73f7ef4991472122ea32402bbc3033eeb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEEwOjNGREYwQzo5RThDNDY6RDMzNzFCOjZCMDA0M0E0IiwidmlzaXRvcl9pZCI6IjkwMjczNTE5Mzg4NzM3MDUzODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacec93349f9d65b7d37c1209a086f9acaf861fd9fdf7d4da6cf538e4df6bb6061b
hovercard-subject-tagissue:894742167
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/5496/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e128184a8bd52baf5e10f1f868b57e88c7cfdccc373a8c059b6034cba2f7212f/python/typeshed/issues/5496
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e128184a8bd52baf5e10f1f868b57e88c7cfdccc373a8c059b6034cba2f7212f/python/typeshed/issues/5496
og:image:altBug Report types.GeneratorType is documented as "The type of generator-iterator objects, created by generator functions." Therefore I would expect that a value annotated using typing.Generator woul...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemthuurne
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
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
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/5496#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F5496
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%2F5496
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/5496
Reloadhttps://github.com/python/typeshed/issues/5496
Reloadhttps://github.com/python/typeshed/issues/5496
pythonhttps://github.com/python
typeshedhttps://github.com/python/typeshed
Codehttps://github.com/python/typeshed
Issues196 (196)https://github.com/python/typeshed/issues
Pull requests252 (252)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/5496
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/5496
#5474https://github.com/python/typeshed/pull/5474
No Generator is considered to be an instance of GeneratorTypehttps://github.com/python/typeshed/issues/5496#top
#5474https://github.com/python/typeshed/pull/5474
https://github.com/mthuurne
mthuurnehttps://github.com/mthuurne
on May 18, 2021https://github.com/python/typeshed/issues/5496#issue-894742167
documented ashttps://docs.python.org/3/library/types.html#types.GeneratorType
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843514362
#5474https://github.com/python/typeshed/pull/5474
https://github.com/mthuurne
mthuurnehttps://github.com/mthuurne
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843521430
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843522305
https://github.com/mthuurne
mthuurnehttps://github.com/mthuurne
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843523977
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843524712
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843524854
JelleZijlstrahttps://github.com/JelleZijlstra
python/mypyhttps://github.com/python/mypy
on May 18, 2021https://github.com/python/typeshed/issues/5496#event-4762811893
https://github.com/mthuurne
mthuurnehttps://github.com/mthuurne
on May 18, 2021https://github.com/python/typeshed/issues/5496#issuecomment-843526041
JelleZijlstrahttps://github.com/JelleZijlstra
completedhttps://github.com/python/typeshed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#5474https://github.com/python/typeshed/pull/5474
on May 18, 2021https://github.com/python/typeshed/issues/5496#event-4762886937
JelleZijlstrahttps://github.com/JelleZijlstra
on May 18, 2021https://github.com/python/typeshed/issues/5496#event-4762887091
make GeneratorType inherit from Generator (#5474)https://github.com/python/typeshed/commit/bce19fc206f45d6029decbdac298e1e3d0f22db7
#5474https://github.com/python/typeshed/pull/5474
https://docs.github.com/articles/closing-issues-via-commit-messages
bce19fchttps://github.com/python/typeshed/commit/bce19fc206f45d6029decbdac298e1e3d0f22db7
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/5496
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/5496
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.