Title: Non-runtime_checkable subclass of a runtime_checkable Protocol allows isinstance() · Issue #132604 · python/cpython · GitHub
Open Graph Title: Non-runtime_checkable subclass of a runtime_checkable Protocol allows isinstance() · Issue #132604 · python/cpython
X Title: Non-runtime_checkable subclass of a runtime_checkable Protocol allows isinstance() · Issue #132604 · python/cpython
Description: Bug report Bug description: I would expect this to raise, but it passes on all versions: from typing import runtime_checkable, Protocol @runtime_checkable class Foo(Protocol): x: int class Bar(Foo, Protocol): y: str isinstance(object(), ...
Open Graph Description: Bug report Bug description: I would expect this to raise, but it passes on all versions: from typing import runtime_checkable, Protocol @runtime_checkable class Foo(Protocol): x: int class Bar(Foo,...
X Description: Bug report Bug description: I would expect this to raise, but it passes on all versions: from typing import runtime_checkable, Protocol @runtime_checkable class Foo(Protocol): x: int class Bar(Foo,...
Opengraph URL: https://github.com/python/cpython/issues/132604
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Non-runtime_checkable subclass of a runtime_checkable Protocol allows isinstance()","articleBody":"# Bug report\n\n### Bug description:\n\nI would expect this to raise, but it passes on all versions:\n\n```py\nfrom typing import runtime_checkable, Protocol\n@runtime_checkable\nclass Foo(Protocol):\n x: int\nclass Bar(Foo, Protocol):\n y: str\nisinstance(object(), Bar)\n```\n\nSome previous discussion in https://github.com/python/cpython/pull/132596#discussion_r2047194339 . We may not want to change this behavior for compatibility reasons, but I think it's a bug so I'm at least opening the issue.\n\n### CPython versions tested on:\n\nCPython main branch, 3.13\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-143806\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2025-04-16T16:43:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/132604/cpython/issues/132604"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2818455b-47cd-2bbc-a917-f3773eb7b874 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BC2:25CBEE:1FA009:2C669B:696A064E |
| html-safe-nonce | 6b34b908391d90db673d460fea89e760eb538d9c71f2add714c97075f1ce643a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkMyOjI1Q0JFRToxRkEwMDk6MkM2NjlCOjY5NkEwNjRFIiwidmlzaXRvcl9pZCI6IjQ5MjAxNDA1NzI3MTA3OTg5MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1043f7e3b09e7aeed3b95774671933b2d320597ae42643cf6eef28a922509a85 |
| hovercard-subject-tag | issue:3000195457 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/132604/issue_layout |
| twitter:image | https://opengraph.githubassets.com/327992fd6f13cf06138792ba86441c36ec21b58b6d7ad766d79b4fc33391d717/python/cpython/issues/132604 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/327992fd6f13cf06138792ba86441c36ec21b58b6d7ad766d79b4fc33391d717/python/cpython/issues/132604 |
| og:image:alt | Bug report Bug description: I would expect this to raise, but it passes on all versions: from typing import runtime_checkable, Protocol @runtime_checkable class Foo(Protocol): x: int class Bar(Foo,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 578c119ff0247c8b2f2491fbf4fc0395cdf909d4df66598cebdc96ddfc4418dc |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 671c2f67171dbced24284331f3133a613d08c366 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width