René's URL Explorer Experiment


Title: (🎁) Add a `StubOnlyBase` decorator for types that don't actually extend things, but do in the stubs (like `Generic`) · Issue #956 · python/typing · GitHub

Open Graph Title: (🎁) Add a `StubOnlyBase` decorator for types that don't actually extend things, but do in the stubs (like `Generic`) · Issue #956 · python/typing

X Title: (🎁) Add a `StubOnlyBase` decorator for types that don't actually extend things, but do in the stubs (like `Generic`) · Issue #956 · python/typing

Description: There are existing classes that extend things in an abstract way, like ABCs, and things that are Generic in theory but not in reality, for example all the collections (the collection classes are not Generics, they define __class_getitem_...

Open Graph Description: There are existing classes that extend things in an abstract way, like ABCs, and things that are Generic in theory but not in reality, for example all the collections (the collection classes are no...

X Description: There are existing classes that extend things in an abstract way, like ABCs, and things that are Generic in theory but not in reality, for example all the collections (the collection classes are no...

Opengraph URL: https://github.com/python/typing/issues/956

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"(🎁) Add a `StubOnlyBase` decorator for types that don't actually extend things, but do in the stubs (like `Generic`)","articleBody":"There are existing classes that extend things in an abstract way, like ABCs, and things that are `Generic` in theory but not in reality, for example all the `collections` (the collection classes are not `Generic`s, they define `__class_getitem__`) and some are still not subscribe-able but state they are in the stubs, for instance `_collections_abc.dict_keys` or any of the collections pre 3.9.\r\n\r\nIt could be used something like:\r\n```py\r\n# _collections_abc.pyi\r\n@StubOnlyBase(KeysView[_KT_co], Generic[_KT_co, _VT_co])\r\nclass dict_keys:\r\n    ...\r\n```\r\n```py\r\n# typing.pyi\r\n\r\n@StubOnlyBase(Generic[_T])\r\nclass Container:\r\n    if sys.version_info >= (3, 9):\r\n        def __class_getitem__(???) -> ???:\r\n\r\n@StubOnlyBase(Collection[_KT], Generic[_KT, _VT_co])\r\nclass Mapping(Collection):\r\n    ...\r\n```\r\n\r\n`Mapping` doesn't actually extend `Generic`, but `Container` defines `__class_getitem__`, so that would also need to be updated in the stubs.\r\n\r\nThis might help resolve https://github.com/python/mypy/issues/3186, but still indicate that it's not actually one of the bases.\r\n```py\r\n# builtins.pyi\r\n@StubOnlyBase(numbers.Integral)\r\nclass int:\r\n    ...\r\n```\r\n\r\nI think a change like this would make the stubs much more understandable and closer to the actual implementation, also fixing issues about older python versions not working properly with the current stubs(https://github.com/python/mypy/issues/11529).\r\n\r\nI personally find it very confusing when referencing the stubs that the bases are often false.\r\n\r\nNo idea how this would be used in a real life annotation, but a workaround that works is:\r\n```py\r\nfrom typing import _alias  # type: ignore[attr-defined]\r\nfrom typing import TYPE_CHECKING\r\nfrom _collections_abc import dict_keys\r\n\r\nif not TYPE_CHECKING:\r\n    dict_keys = _alias(dict_keys, 2)\r\n\r\ndef foo(dk: dict_keys[str, int]) -> None: ...\r\n```\r\n\r\nhttps://github.com/python/typeshed/pull/6312#issuecomment-976036379\r\nhttps://github.com/python/typeshed/issues/6257\r\n\r\nObligatory shill to #953, which I think would render this moot.","author":{"url":"https://github.com/KotlinIsland","@type":"Person","name":"KotlinIsland"},"datePublished":"2021-11-23T05:15:37Z","url":"https://github.com/python/typing/issues/956"}

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:96950d5b-7d8d-733d-92a0-37e2b49f64cf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8F84:1AD4B2:85AB:B1E7:6B0016E4
html-safe-nonce997c442cbfb2c7d3d3c6907c1912687502fee031397cdd8f069ea2de46ff01ea
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Rjg0OjFBRDRCMjo4NUFCOkIxRTc6NkIwMDE2RTQiLCJ2aXNpdG9yX2lkIjoiODY3NjA4MTQ0MTUwMDU2NzI2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac48968570a7e8b236aed1abe03182ebcb55d7ce42fc1ad04ae2b42328da1ec098
hovercard-subject-tagissue:1060848005
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/typing/956/issue_layout
twitter:imagehttps://opengraph.githubassets.com/04e47191b2e0da765f10f69486e20e6866f65815fc8563ee77c18fde8a03a47e/python/typing/issues/956
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/04e47191b2e0da765f10f69486e20e6866f65815fc8563ee77c18fde8a03a47e/python/typing/issues/956
og:image:altThere are existing classes that extend things in an abstract way, like ABCs, and things that are Generic in theory but not in reality, for example all the collections (the collection classes are no...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKotlinIsland
hostnamegithub.com
expected-hostnamegithub.com
Nonea2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4
turbo-cache-controlno-preview
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
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/typing/issues/956#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F956
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%2Ftyping%2Fissues%2F956
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%2Ftyping
Reloadhttps://github.com/python/typing/issues/956
Reloadhttps://github.com/python/typing/issues/956
Reloadhttps://github.com/python/typing/issues/956
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
https://github.com/python/typing
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/956
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/956
(🎁) Add a StubOnlyBase decorator for types that don't actually extend things, but do in the stubs (like Generic)https://github.com/python/typing/issues/956#top
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
https://github.com/KotlinIsland
KotlinIslandhttps://github.com/KotlinIsland
on Nov 23, 2021https://github.com/python/typing/issues/956#issue-1060848005
python/mypy#3186https://github.com/python/mypy/issues/3186
python/mypy#11529https://github.com/python/mypy/issues/11529
python/typeshed#6312 (comment)https://github.com/python/typeshed/pull/6312#issuecomment-976036379
python/typeshed#6257https://github.com/python/typeshed/issues/6257
#953https://github.com/python/typing/issues/953
KotlinIslandhttps://github.com/KotlinIsland
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
on Nov 23, 2021https://github.com/python/typing/issues/956#event-5658055133
KotlinIslandhttps://github.com/KotlinIsland
on Nov 23, 2021https://github.com/python/typing/issues/956#event-5658342914
KotlinIslandhttps://github.com/KotlinIsland
on Nov 23, 2021https://github.com/python/typing/issues/956#event-5658374305
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 23, 2021https://github.com/python/typing/issues/956#issuecomment-976569692
python/cpython#29355https://github.com/python/cpython/pull/29355
https://github.com/KotlinIsland
KotlinIslandhttps://github.com/KotlinIsland
on Nov 23, 2021https://github.com/python/typing/issues/956#issuecomment-977241859
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 23, 2021https://github.com/python/typing/issues/956#issuecomment-977244366
https://github.com/KotlinIsland
KotlinIslandhttps://github.com/KotlinIsland
on Nov 23, 2021https://github.com/python/typing/issues/956#issuecomment-977291857
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Nov 23, 2021https://github.com/python/typing/issues/956#issuecomment-977299150
my previous PR to cpythonhttps://github.com/python/cpython/pull/29355
herehttps://github.com/python/typing/issues/956#issuecomment-976569692
https://github.com/not-my-profile
not-my-profilehttps://github.com/not-my-profile
on Mar 4, 2022https://github.com/python/typing/issues/956#issuecomment-1059119089
python/typeshed#7436https://github.com/python/typeshed/issues/7436
all use snake_casehttps://docs.python.org/3/library/typing.html#functions-and-decorators
@typing.type_check_onlyhttps://docs.python.org/3/library/typing.html#typing.type_check_only
@srittauhttps://github.com/srittau
@JelleZijlstrahttps://github.com/JelleZijlstra
KotlinIslandhttps://github.com/KotlinIsland
on Jul 3, 2022https://github.com/python/typing/issues/956#event-6923255870
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/956
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/956
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%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.