René's URL Explorer Experiment


Title: Deriving builtins from ABCs implies incorrect and problematic metaclass structure · Issue #1595 · python/typeshed · GitHub

Open Graph Title: Deriving builtins from ABCs implies incorrect and problematic metaclass structure · Issue #1595 · python/typeshed

X Title: Deriving builtins from ABCs implies incorrect and problematic metaclass structure · Issue #1595 · python/typeshed

Description: typeshed claims that str derives from Sequence and therefore indirectly from collections_abc.Sized whose metaclass is declared to be ABCMeta. This is done as a type-checkable alternative to Sequence.register(str) which handles isinstance...

Open Graph Description: typeshed claims that str derives from Sequence and therefore indirectly from collections_abc.Sized whose metaclass is declared to be ABCMeta. This is done as a type-checkable alternative to Sequenc...

X Description: typeshed claims that str derives from Sequence and therefore indirectly from collections_abc.Sized whose metaclass is declared to be ABCMeta. This is done as a type-checkable alternative to Sequenc...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Deriving builtins from ABCs implies incorrect and problematic metaclass structure","articleBody":"typeshed [claims](https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L233) that `str` derives from [`Sequence`](https://github.com/python/typing/blob/master/src/typing.py#L1846) and therefore indirectly from [`collections_abc.Sized`](https://github.com/python/cpython/blob/3.6/Lib/_collections_abc.py#L359) whose metaclass is declared to be ABCMeta. This is done as a type-checkable alternative to `Sequence.register(str)` which handles isinstance and issubclass calls.\r\n\r\nHowever derivation and register are not indistinguishable, since the metaclass structure is different. `issubclass(type(str), ABCMeta)` should be False, otherwise the definition `class A(str, Enum): pass` would fail at runtime due to inconsistent metaclass structure:\r\n```\r\n>>> from collections import Sized\r\n>>> from enum import Enum\r\n>>> class A(Sized, Enum): pass\r\n...\r\nTraceback (most recent call last):\r\n  File \"\u003cstdin>\", line 1, in \u003cmodule>\r\nTypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases\r\n```\r\nThe error is that `type(Enum) is EnumMeta` and `type(Sized) is ABCMeta` and they are unrelated.\r\n\r\nThis bug has at least the following implications:\r\n* It obviously implies that `a: ABCMeta = str` typechecks.\r\n* It makes it harder to warn about inconsistent metaclass structure without false positives. This is why mypy only catches specific cases.\r\n* As exemplified above, `class A(str, Enum)` appears to have inconsistent metaclass structure, even though this is the recommended way of making an enum of strings. It might also be the case with some other builtins.","author":{"url":"https://github.com/elazarg","@type":"Person","name":"elazarg"},"datePublished":"2017-09-08T15:23:49Z","url":"https://github.com/python/typeshed/issues/1595"}

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:de5f1316-9efd-df1b-5e08-df7271119122
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE74A:1BEF18:1C18C6F:25C5618:6B0005E5
html-safe-nonced82af59b16b17682a572b72493aa7aa835edf97f42e184f686bf435708b5c1ab
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzRBOjFCRUYxODoxQzE4QzZGOjI1QzU2MTg6NkIwMDA1RTUiLCJ2aXNpdG9yX2lkIjoiMjU1OTI5MTc0NDU0MTc1MjA1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2e462832c6a9397965256d4b260f43b8d0dd110f15187b8729ba3a2951cb3a4e
hovercard-subject-tagissue:256288832
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/1595/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e8269239b59f8f4c458f6f351a263adaa0ad4ac1db08b135027307c0d6b3b583/python/typeshed/issues/1595
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e8269239b59f8f4c458f6f351a263adaa0ad4ac1db08b135027307c0d6b3b583/python/typeshed/issues/1595
og:image:alttypeshed claims that str derives from Sequence and therefore indirectly from collections_abc.Sized whose metaclass is declared to be ABCMeta. This is done as a type-checkable alternative to Sequenc...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameelazarg
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
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
release16a11879678aaf97e2a42c33ee70830aa084fa37
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/1595#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F1595
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%2F1595
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/1595
Reloadhttps://github.com/python/typeshed/issues/1595
Reloadhttps://github.com/python/typeshed/issues/1595
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/1595
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/1595
Deriving builtins from ABCs implies incorrect and problematic metaclass structurehttps://github.com/python/typeshed/issues/1595#top
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/elazarg
elazarghttps://github.com/elazarg
on Sep 8, 2017https://github.com/python/typeshed/issues/1595#issue-256288832
claimshttps://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L233
Sequencehttps://github.com/python/typing/blob/master/src/typing.py#L1846
collections_abc.Sizedhttps://github.com/python/cpython/blob/3.6/Lib/_collections_abc.py#L359
https://github.com/elazarg
elazarghttps://github.com/elazarg
on Sep 8, 2017https://github.com/python/typeshed/issues/1595#issuecomment-328138533
@ilevkivskyihttps://github.com/ilevkivskyi
@JukkaLhttps://github.com/JukkaL
@JukkaLhttps://github.com/JukkaL
python-ideashttps://mail.python.org/pipermail/python-ideas/2017-September/046993.html
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Sep 8, 2017https://github.com/python/typeshed/issues/1595#issuecomment-328224704
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Sep 8, 2017https://github.com/python/typeshed/issues/1595#issuecomment-328226924
elazarghttps://github.com/elazarg
on Sep 10, 2017https://github.com/python/typeshed/issues/1595#event-1242270683
Derive EnumMeta from ABCMetahttps://github.com/elazarg/typeshed/commit/963f76d1dc4703552bd3913e6172f726f52aee9c
963f76dhttps://github.com/elazarg/typeshed/commit/963f76d1dc4703552bd3913e6172f726f52aee9c
Derive EnumMeta from ABCMetahttps://github.com/elazarg/typeshed/commit/88cf09d77165e3b42b0bd60dc0873123c0419e50
88cf09dhttps://github.com/elazarg/typeshed/commit/88cf09d77165e3b42b0bd60dc0873123c0419e50
JelleZijlstrahttps://github.com/JelleZijlstra
on Sep 11, 2017https://github.com/python/typeshed/issues/1595#event-1242402372
Derive EnumMeta from ABCMeta (#1598)https://github.com/python/typeshed/commit/d4b21efbe832b5e3b3a1781c3dff2fe072b01559
#1598https://github.com/python/typeshed/pull/1598
d4b21efhttps://github.com/python/typeshed/commit/d4b21efbe832b5e3b3a1781c3dff2fe072b01559
https://github.com/Zac-HD
Zac-HDhttps://github.com/Zac-HD
on Oct 15, 2017https://github.com/python/typeshed/issues/1595#issuecomment-336712091
HypothesisWorks/hypothesis#858https://github.com/HypothesisWorks/hypothesis/pull/858
https://github.com/elazarg
elazarghttps://github.com/elazarg
on Oct 15, 2017https://github.com/python/typeshed/issues/1595#issuecomment-336713742
@Zac-HDhttps://github.com/Zac-HD
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Oct 15, 2017https://github.com/python/typeshed/issues/1595#issuecomment-336716918
srittauhttps://github.com/srittau
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
size-mediumhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22size-medium%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
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
on Oct 28, 2018https://github.com/python/typeshed/issues/1595#event-1930723964
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Jun 20, 2022https://github.com/python/typeshed/issues/1595#issuecomment-1160962061
https://github.com/python/typinghttps://github.com/python/typing
hauntsaninjahttps://github.com/hauntsaninja
not plannedhttps://github.com/python/typeshed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Jun 20, 2022https://github.com/python/typeshed/issues/1595#event-6842638400
srittauhttps://github.com/srittau
Builtin classes have a register method, because of Protocol inheritance #13466https://github.com/python/typeshed/issues/13466
on Feb 26, 2025https://github.com/python/typeshed/issues/1595#event-16480158390
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/1595
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/1595
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.