René's URL Explorer Experiment


Title: Relaxing usage of `type` with `typing.Protocol` in typing spec · Issue #2306 · python/typing · GitHub

Open Graph Title: Relaxing usage of `type` with `typing.Protocol` in typing spec · Issue #2306 · python/typing

X Title: Relaxing usage of `type` with `typing.Protocol` in typing spec · Issue #2306 · python/typing

Description: Some time ago I opened a thread on the Python discourse about implementing an AbstractType semantic that would allow functions to receive non-instantiable types so to try and conform a bit the situation presented in the the thread. Consi...

Open Graph Description: Some time ago I opened a thread on the Python discourse about implementing an AbstractType semantic that would allow functions to receive non-instantiable types so to try and conform a bit the situ...

X Description: Some time ago I opened a thread on the Python discourse about implementing an AbstractType semantic that would allow functions to receive non-instantiable types so to try and conform a bit the situ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Relaxing usage of `type` with `typing.Protocol` in typing spec","articleBody":"Some time ago I opened [a thread](https://discuss.python.org/t/abstracttype-take-2-or-allowing-typeform-to-be-used-in-isinstance/107093) on the Python discourse about implementing an `AbstractType` semantic that would allow functions to receive non-instantiable types so to try and conform a bit the situation presented in the the thread.\n\nConsider the snippet:\n\n```py\nfrom abc import abstractmethod\nfrom typing import runtime_checkable, Protocol, TypeVar, TypeGuard\n\n@runtime_checkable\nclass MyProtocol(Protocol):\n    @abstractmethod\n    def my_method(self) -> str:\n        ...\n\nclass MyClass:\n    def my_method(self) -> str:\n        return \"Hello from MyClass!\"\n    \nclass MyOtherClass:\n    def another_method(self) -> str:\n        return \"Hello from MyOtherClass!\"\n    \n\nP = TypeVar('P', bound=MyProtocol)\n    \ndef check_protocol(obj: object, protocol: type[P]) -> TypeGuard[P]:\n    return isinstance(obj, protocol)\n\n# Example usage\nmy_obj = MyClass()\nmy_other_obj = MyOtherClass()\nif check_protocol(my_obj, MyProtocol):\n    print(my_obj.my_method())\nif check_protocol(my_other_obj, MyProtocol):\n    print(my_other_obj.my_method())\nelse:\n    print(\"Object does not implement MyProtocol.\")\n```\n\nOutput:\n\n```\nHello from MyClass!\nmy_obj does not implement MyOtherClass protocol.\n```\n\nAt runtime, this works as intended. At type checking time, `mypy` complains that `check_protocol` cannot accept a non-instantiable type, while `pyright` and `ty` are accepting this behavior.\n\nAccording to the typing specification, `mypy` is technically correct (the best kind of correct), but this code is perfectly acceptable. There are other examples referenced in python/mypy#4717 (which is the 3rd most upvoted issue by 👍 by the way).\n\nI was hoping for more discussion points presented in the thread but not many replied. I didn't want to monopolize it, so I'm trying my luck here.\n\n@JelleZijlstra (sorry for the ping) did point out that it might be worthwhile to change the spec to allow this behavior but I'm guessing there should be some discussion on how to deal with it first. Jelle suggested: \"If you want it to be instantiable, use `Callable[]` instead.\"\n\nI do agree it makes sense, but this snippet:\n\n```py\nfrom typing import Protocol\n\nclass MyProtocol(Protocol):\n    def method(self) -> str:\n        ...\nprint(callable(MyProtocol)) # prints True\n```\n\nconfuses me.\n\nSo my point is: could the spec allow for `type` to accept non-instantiable types, since it seems to be a pretty common pattern? Is there a way to effectively deal with the separation between instantiable and non-instantiable types?\n\nI tried adding the \"typing spec\" label but couldn't. At any rate, thank you for the consideration.","author":{"url":"https://github.com/jacopoabramo","@type":"Person","name":"jacopoabramo"},"datePublished":"2026-06-18T09:10:16Z","url":"https://github.com/python/typing/issues/2306"}

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:bf7dd689-0278-ba96-8706-4006f70061f1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id853E:2EC689:69508A:8DCBDA:6AFF8C72
html-safe-noncee17833a51c9c15dfc3db8b52a1324c3d2fb5f63f2d0567901121f5ddeb59655a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTNFOjJFQzY4OTo2OTUwOEE6OERDQkRBOjZBRkY4QzcyIiwidmlzaXRvcl9pZCI6IjczOTg2NTI0NDcwNTAxNDA3ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc214829187ce76a96e5dba8218551f7ac5b2bd502b02486904808e532ae58fc5
hovercard-subject-tagissue:4690895431
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/2306/issue_layout
twitter:imagehttps://opengraph.githubassets.com/eb35a51af6a8abeade074468db3528c7ab128b89bbd9c14b32fdad82527d37ce/python/typing/issues/2306
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/eb35a51af6a8abeade074468db3528c7ab128b89bbd9c14b32fdad82527d37ce/python/typing/issues/2306
og:image:altSome time ago I opened a thread on the Python discourse about implementing an AbstractType semantic that would allow functions to receive non-instantiable types so to try and conform a bit the situ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejacopoabramo
hostnamegithub.com
expected-hostnamegithub.com
None587ad99a3e443b2e1cb0d3df059ec49ab54389861f13310766dfdeb615fed90d
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
release5bb0fb68d64881d1344f5863d809515d496801e5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typing/issues/2306#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F2306
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%2F2306
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/2306
Reloadhttps://github.com/python/typing/issues/2306
Reloadhttps://github.com/python/typing/issues/2306
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/2306
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/2306
Relaxing usage of type with typing.Protocol in typing spechttps://github.com/python/typing/issues/2306#top
topic: typing specFor improving the typing spechttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20typing%20spec%22
https://github.com/jacopoabramo
jacopoabramohttps://github.com/jacopoabramo
on Jun 18, 2026https://github.com/python/typing/issues/2306#issue-4690895431
a threadhttps://discuss.python.org/t/abstracttype-take-2-or-allowing-typeform-to-be-used-in-isinstance/107093
python/mypy#4717https://github.com/python/mypy/issues/4717
@JelleZijlstrahttps://github.com/JelleZijlstra
jacopoabramohttps://github.com/jacopoabramo
topic: otherOther topics not coveredhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20other%22
on Jun 18, 2026https://github.com/python/typing/issues/2306#event-26902773890
srittauhttps://github.com/srittau
topic: typing specFor improving the typing spechttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20typing%20spec%22
topic: otherOther topics not coveredhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20other%22
on Jun 18, 2026https://github.com/python/typing/issues/2306#event-26908113397
https://github.com/davidhalter
davidhalterhttps://github.com/davidhalter
on Jun 18, 2026https://github.com/python/typing/issues/2306#issuecomment-4742247179
https://github.com/jacopoabramo
jacopoabramohttps://github.com/jacopoabramo
on Jun 18, 2026https://github.com/python/typing/issues/2306#issuecomment-4742286928
https://github.com/jacopoabramo
jacopoabramohttps://github.com/jacopoabramo
on Jul 13, 2026https://github.com/python/typing/issues/2306#issuecomment-4956666865
@davidhalterhttps://github.com/davidhalter
this commenthttps://github.com/python/mypy/issues/4717#issuecomment-1751451905
thishttps://github.com/python/mypy/issues/4717#issuecomment-2145389992
this usage with attrshttps://github.com/python/mypy/issues/4717#issuecomment-2145389992
This commenthttps://github.com/python/mypy/issues/4717#issuecomment-1546846141
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/2306
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/2306
topic: typing specFor improving the typing spechttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20typing%20spec%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.