René's URL Explorer Experiment


Title: Allow subclassing without supertyping · Issue #241 · python/typing · GitHub

Open Graph Title: Allow subclassing without supertyping · Issue #241 · python/typing

X Title: Allow subclassing without supertyping · Issue #241 · python/typing

Description: This issue comes from python/mypy#1237. I'll try to make a summary of the discussion here Some one reported an issue with an artificial example (python/mypy#1237 (comment)): class Foo: def factory(self) -> str: return 'Hello' class Bar(F...

Open Graph Description: This issue comes from python/mypy#1237. I'll try to make a summary of the discussion here Some one reported an issue with an artificial example (python/mypy#1237 (comment)): class Foo: def factory(...

X Description: This issue comes from python/mypy#1237. I'll try to make a summary of the discussion here Some one reported an issue with an artificial example (python/mypy#1237 (comment)): class Foo: def fact...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow subclassing without supertyping","articleBody":"This issue comes from python/mypy#1237. I'll try to make a summary of the discussion here\n\nSome one reported an issue with an artificial example (https://github.com/python/mypy/issues/1237#issue-136162181):\n\n``` python\nclass Foo:\n    def factory(self) -> str:\n        return 'Hello'\n\nclass Bar(Foo):\n    def factory(self) -> int:\n        return 10\n```\n\nand then with the following stub files (https://github.com/python/mypy/issues/1237#issuecomment-188710925):\n\n``` python\nclass QPixmap(QPaintDevice):\n    def swap(self, other: 'QPixmap') -> None: ...\n\nclass QBitmap(QPixmap):\n    def swap(self, other: 'QBitmap') -> None: ...\n```\n\nWhich mypy currently reports as erroneous: `Argument 1 of \"swap\" incompatible with supertype \"QPixmap\"`\n\nThese were initially was argued to be a correct error because they violate Liskov Substitution Principle (the same case by a change of return type, the second is a covariant argument change). The problem in this scenario is that the actual classes are not meant to be substituted (the first example is actually a wrapper for a non-virtual C++ function so they're not substitutable, and the second aren't supposed to be mixed together, just reuse part of the code). (see https://github.com/python/mypy/issues/1237#issuecomment-189490903)\n\nThere was also a suggestion that allow covariant args explicitly (in the same way that Eiffel allows it and adds a runtime check) with a decorator\n\n``` python\nclass QBitmap(QPixmap):\n    @covariant_args\n    def swap(self, other: 'QBitmap') -> None: ...\n```\n\nMy proposal instead was add what some dialects of Eiffel call \"non-conforming inheritance\" (\"conforms\" is the Eiffel word for what PEP-483 calls \"is-consistent-with\"). It is essentially a mechanism to use subclassing just as a way to get the implementation from the superclass without creating a subtyping relation between them. See https://github.com/python/mypy/issues/1237#issuecomment-231199419 for a detailed explanation.\n\nThe proposal is to haven `Implementation` in typing so you can write:\n\n``` python\nclass QBitmap(Implementation[QPixmap]):\n    def swap(self, other: 'QBitmap') -> None: ...\n```\n\nwhich just defines a `QBitmap` class with all the mothods copied from `QPixmap`, but without making one a subtype of the other. In runtime we can just make `Implementation[QPixmap] == QPixmap`\n","author":{"url":"https://github.com/dmoisset","@type":"Person","name":"dmoisset"},"datePublished":"2016-07-08T12:57:10Z","url":"https://github.com/python/typing/issues/241"}

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:b5939bd9-3fe2-17a4-8d6f-e62d201f0c61
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id99C6:3DCBB0:38A074:4F9459:6B006F68
html-safe-noncee2f0c072b24958842963e50b97ffdc48c259ca56f69b1f7b49ca53d7efce29d9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUM2OjNEQ0JCMDozOEEwNzQ6NEY5NDU5OjZCMDA2RjY4IiwidmlzaXRvcl9pZCI6IjE5NzYwNDY3MjczNDU1MDAwMDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac587418e61bbddaa71e676493e3d9e6ba2836dfc6edef2058c9cc21c1c75c11fa
hovercard-subject-tagissue:164525166
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/241/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4c444dab6bb8b39688ce88c8aba67a7492dc696bb8d8f62f51e2f325160cb861/python/typing/issues/241
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4c444dab6bb8b39688ce88c8aba67a7492dc696bb8d8f62f51e2f325160cb861/python/typing/issues/241
og:image:altThis issue comes from python/mypy#1237. I'll try to make a summary of the discussion here Some one reported an issue with an artificial example (python/mypy#1237 (comment)): class Foo: def factory(...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedmoisset
hostnamegithub.com
expected-hostnamegithub.com
None6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa
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
release46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typing/issues/241#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F241
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%2F241
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/241
Reloadhttps://github.com/python/typing/issues/241
Reloadhttps://github.com/python/typing/issues/241
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/241
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/241
Allow subclassing without supertypinghttps://github.com/python/typing/issues/241#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/dmoisset
dmoissethttps://github.com/dmoisset
on Jul 8, 2016https://github.com/python/typing/issues/241#issue-164525166
python/mypy#1237https://github.com/python/mypy/issues/1237
python/mypy#1237 (comment)https://github.com/python/mypy/issues/1237#issue-136162181
python/mypy#1237 (comment)https://github.com/python/mypy/issues/1237#issuecomment-188710925
python/mypy#1237 (comment)https://github.com/python/mypy/issues/1237#issuecomment-189490903
PEP-483https://peps.python.org/483
python/mypy#1237 (comment)https://github.com/python/mypy/issues/1237#issuecomment-231199419
Nexthttps://github.com/python/typing/issues/241?timeline_page=1
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Jul 8, 2016https://github.com/python/typing/issues/241#issuecomment-231354716
@gvanrossumhttps://github.com/gvanrossum
https://github.com/dmoisset
dmoissethttps://github.com/dmoisset
on Jul 8, 2016https://github.com/python/typing/issues/241#issuecomment-231356915
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jul 10, 2016https://github.com/python/typing/issues/241#issuecomment-231579143
@dmoissethttps://github.com/dmoisset
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jul 10, 2016https://github.com/python/typing/issues/241#issuecomment-231607211
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232683012
@JukkaLhttps://github.com/JukkaL
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232708629
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232712153
@JukkaLhttps://github.com/JukkaL
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232715982
python/mypy#1237https://github.com/python/mypy/issues/1237
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232717908
@gvanrossumhttps://github.com/gvanrossum
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232719025
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232721571
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232722544
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232726411
@JukkaLhttps://github.com/JukkaL
@gvanrossumhttps://github.com/gvanrossum
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232728938
@gvanrossumhttps://github.com/gvanrossum
@ilevkivskyihttps://github.com/ilevkivskyi
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Jul 14, 2016https://github.com/python/typing/issues/241#issuecomment-232729057
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Apr 8, 2017https://github.com/python/typing/issues/241#issuecomment-292694838
https://github.com/mitar
mitarhttps://github.com/mitar
on Sep 26, 2017https://github.com/python/typing/issues/241#issuecomment-332089088
sklearnhttp://scikit-learn.org
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Sep 26, 2017https://github.com/python/typing/issues/241#issuecomment-332233042
@mitarhttps://github.com/mitar
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Sep 26, 2017https://github.com/python/typing/issues/241#issuecomment-332234939
https://github.com/mitar
mitarhttps://github.com/mitar
on Oct 12, 2017https://github.com/python/typing/issues/241#issuecomment-336027565
https://github.com/danmou
danmouhttps://github.com/danmou
on Oct 18, 2019https://github.com/python/typing/issues/241#issuecomment-543817369
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Oct 18, 2019https://github.com/python/typing/issues/241#issuecomment-543960128
https://github.com/danmou
danmouhttps://github.com/danmou
on Oct 20, 2019https://github.com/python/typing/issues/241#issuecomment-544251018
@JelleZijlstrahttps://github.com/JelleZijlstra
https://github.com/ziima
ziimahttps://github.com/ziima
on Oct 22, 2019https://github.com/python/typing/issues/241#issuecomment-544863588
@gvanrossumhttps://github.com/gvanrossum
https://github.com/leonardoramirezr
leonardoramirezrhttps://github.com/leonardoramirezr
on Jul 9, 2020https://github.com/python/typing/issues/241#issuecomment-656350517
srittauhttps://github.com/srittau
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
enhancementhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Nov 4, 2021https://github.com/python/typing/issues/241#event-5567244124
https://github.com/minrk
minrkhttps://github.com/minrk
on Jan 11, 2022https://github.com/python/typing/issues/241#issuecomment-1009992873
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Jan 11, 2022https://github.com/python/typing/issues/241#issuecomment-1009996659
@minrkhttps://github.com/minrk
https://github.com/minrk
minrkhttps://github.com/minrk
on Jan 11, 2022https://github.com/python/typing/issues/241#issuecomment-1010051144
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/241
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/241
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.