René's URL Explorer Experiment


Title: Protocols by ilevkivskyi · Pull Request #417 · python/typing · GitHub

Open Graph Title: Protocols by ilevkivskyi · Pull Request #417 · python/typing

X Title: Protocols by ilevkivskyi · Pull Request #417 · python/typing

Description: Fixes #11 This is a runtime implementation of protocols as per draft PEP 544. (The mypy counterpart is python/mypy#3132) The implementation is straightforward (mostly I just made current version to behave more similar to __subclasshook__ in collections.abc and added support for __annotations__ in Python 3.6). Nevertheless, I add a lot of tests. Some of them may look trivial, but previous experience with generics shows that it is better to have them. There is probably only one corner case worth noting. Consider this situation with for variable annotations: @runtime class Proto(Protocol): attr: int class OtherProto(Protocol): attr: int class BadConcrete: attr: int class GoodConcrete: attr = 1 Then I propose the following subclass check results: issubclass(GoodConcrete, Proto) == True issubclass(BadConcrete, Proto) == False # This is a bit questionable, maybe return True? issubclass(OtherProto, Proto) == True The first one is probably obvious, the second one returns False to make this safe: if issubclass(BadConcrete, Proto): BadConcrete().attr The last one although safe since one cannot instantiate protocols, and this is probably what one would expect. Attn: @JukkaL @ambv @gvanrossum

Open Graph Description: Fixes #11 This is a runtime implementation of protocols as per draft PEP 544. (The mypy counterpart is python/mypy#3132) The implementation is straightforward (mostly I just made current version to...

X Description: Fixes #11 This is a runtime implementation of protocols as per draft PEP 544. (The mypy counterpart is python/mypy#3132) The implementation is straightforward (mostly I just made current version to...

Opengraph URL: https://github.com/python/typing/pull/417

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:fcae84f9-4632-1d27-fb6b-2a95e587052e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9392:1F7A:B300F0:F337D4:6AFFFB1D
html-safe-noncec7f06c2a12148f6e1e2ddaf9266a42213f72084a805018c72ac49be44e853e4f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzkyOjFGN0E6QjMwMEYwOkYzMzdENDo2QUZGRkIxRCIsInZpc2l0b3JfaWQiOiI2MTI5ODY0NTY2MDIyMDc3MjEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac5f716b07790ad1bc3f5ca61aa420d9cac5714bc1a0f63f2a9b594f68908a98c4
hovercard-subject-tagpull_request:117753283
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/typing/pull/417/files
twitter:imagehttps://avatars.githubusercontent.com/u/12005495?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/12005495?s=400&v=4
og:image:altFixes #11 This is a runtime implementation of protocols as per draft PEP 544. (The mypy counterpart is python/mypy#3132) The implementation is straightforward (mostly I just made current version to...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
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

Links:

Skip to contenthttps://github.com/python/typing/pull/417/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fpull%2F417%2Ffiles
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%2Fpull%2F417%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Ftyping
Reloadhttps://github.com/python/typing/pull/417/files
Reloadhttps://github.com/python/typing/pull/417/files
Reloadhttps://github.com/python/typing/pull/417/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Ftyping%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Ftyping%2Fissues%2Fnew%2Fchoose
ilevkivskyihttps://github.com/ilevkivskyi
python:masterhttps://github.com/python/typing/tree/master
ilevkivskyi:protocolshttps://github.com/ilevkivskyi/typehinting/tree/protocols
Conversation 6 https://github.com/python/typing/pull/417
Commits 19 https://github.com/python/typing/pull/417/commits
Checks 0 https://github.com/python/typing/pull/417/checks
Files changed https://github.com/python/typing/pull/417/files
Please reload this pagehttps://github.com/python/typing/pull/417/files
Protocols https://github.com/python/typing/pull/417/files#top
Show all changes 19 commits https://github.com/python/typing/pull/417/files
de21b02 Initial ideas for runtime implementation of protocols ilevkivskyi Apr 19, 2017 https://github.com/python/typing/pull/417/commits/de21b02b541a1e07ee1f9e9d1fa3824eaaf134f5
6a31a93 Uniform class and instance checks (same as collections.abc) ilevkivskyi Apr 23, 2017 https://github.com/python/typing/pull/417/commits/6a31a93b96007d1a60b34df469d93d3d4f62fddf
f107299 Fix lint ilevkivskyi Apr 23, 2017 https://github.com/python/typing/pull/417/commits/f1072994dad1cd1183aa43dca9e0600a46f011b1
8e07b88 Simplify code using absence of non-protocol bases + some support for … ilevkivskyi Apr 23, 2017 https://github.com/python/typing/pull/417/commits/8e07b885f0159e513e01afdee8b3ea06bdc0fa6e
e3db3de Better support for isinstance(); add some tests ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/e3db3de4f8f95ccf9bc3e3450e443657592cbce3
e580511 Minor fixes ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/e580511940d83a258c02d5c3011230b8fcb3e0bd
d99d9ef Add more tests; improve docstrings ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/d99d9ef8537d8564b4585c8dff12cdaaac478b1c
831e1a7 Add support for extending collections protocols (+ tests) ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/831e1a7f65bf7a08eb6a0b6e299545bbc50fcb27
a932e9f Fix behaviour in different veriosns ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/a932e9faa38f429afbfd0acf84145b7c4b35d2df
3e34f7a More compatibility fixes ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/3e34f7adb77c93fac1b2b1c0888fed93ac63bec2
8483810 Fix typos and lint ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/8483810ce54fdce9e318db5700c19860819d2a40
9e7b674 Even more compatibility fixes ilevkivskyi Apr 24, 2017 https://github.com/python/typing/pull/417/commits/9e7b6740616afe44a9a9b872fe130373f9fee6a8
8ee5b71 Reorganize code more logically (hopefully this will also reduce diff) Apr 25, 2017 https://github.com/python/typing/pull/417/commits/8ee5b712abf655d851d7c8282bef505434eb522e
4a0d335 Add tests for PY36 and @abstracmethod ilevkivskyi Apr 25, 2017 https://github.com/python/typing/pull/417/commits/4a0d335ca2611564f6925bd263f16143462147cd
8fc9a5e Backport protocols to Python 2 ilevkivskyi Apr 25, 2017 https://github.com/python/typing/pull/417/commits/8fc9a5e9d16b850a45e6ff9b80b7ac449019ee3e
b6e526e Corner case for PEP 526 subprotocols ilevkivskyi Apr 26, 2017 https://github.com/python/typing/pull/417/commits/b6e526e23b2d78298e4995bdb4183cab92b6c89c
d3a5491 Add test for named tuple with protocol ilevkivskyi May 13, 2017 https://github.com/python/typing/pull/417/commits/d3a5491e6e7349acddba7d3e2b7f75f75a965859
eecef84 Merge branch 'master' into protocols ilevkivskyi Jul 28, 2017 https://github.com/python/typing/pull/417/commits/eecef84c3eb14d85cb8dc7c1cd5ebd140fc995b6
904c978 Fix broken merge ilevkivskyi Jul 28, 2017 https://github.com/python/typing/pull/417/commits/904c978670102c6e116c096bc3706e290f801237
Clear filters https://github.com/python/typing/pull/417/files
Please reload this pagehttps://github.com/python/typing/pull/417/files
Please reload this pagehttps://github.com/python/typing/pull/417/files
test_typing.py https://github.com/python/typing/pull/417/files#diff-f23c53e6fa002cdeac74b9499d744b9492bfd34a58ce281c2b5076e628d0083a
typing.py https://github.com/python/typing/pull/417/files#diff-cbea31cd6366bdaf7805202979325ba4b14a29613bb7aeaecf9a18e94ea93619
test_typing.py https://github.com/python/typing/pull/417/files#diff-e618ee6a4894a62d9269e41c4dc836e31e8224cfb66b5be3b325f4798ec245e3
typing.py https://github.com/python/typing/pull/417/files#diff-ad6da8dfad5c336100410e57073641a0266b69e1801476d2b1e593b2c04f81f5
Please reload this pagehttps://github.com/python/typing/pull/417/files
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.