Title: `isinstance` on `runtime_checkable` `Protocol` has side-effects for `@property` methods · Issue #102433 · python/cpython · GitHub
Open Graph Title: `isinstance` on `runtime_checkable` `Protocol` has side-effects for `@property` methods · Issue #102433 · python/cpython
X Title: `isinstance` on `runtime_checkable` `Protocol` has side-effects for `@property` methods · Issue #102433 · python/cpython
Description: For example: from typing import Protocol, runtime_checkable @runtime_checkable class X(Protocol): @property def myproperty(self): ... class Y: @property def myproperty(self): raise RuntimeError("hallo") isinstance(Y(), X) will raise the ...
Open Graph Description: For example: from typing import Protocol, runtime_checkable @runtime_checkable class X(Protocol): @property def myproperty(self): ... class Y: @property def myproperty(self): raise RuntimeError("ha...
X Description: For example: from typing import Protocol, runtime_checkable @runtime_checkable class X(Protocol): @property def myproperty(self): ... class Y: @property def myproperty(self): raise RuntimeError(&qu...
Opengraph URL: https://github.com/python/cpython/issues/102433
X: @github
Domain: togithub.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`isinstance` on `runtime_checkable` `Protocol` has side-effects for `@property` methods","articleBody":"For example:\r\n\r\n```python\r\nfrom typing import Protocol, runtime_checkable\r\n\r\n@runtime_checkable\r\nclass X(Protocol):\r\n @property\r\n def myproperty(self): ...\r\n\r\nclass Y:\r\n @property\r\n def myproperty(self):\r\n raise RuntimeError(\"hallo\")\r\n\r\nisinstance(Y(), X)\r\n```\r\n\r\nwill raise the `RuntimeError`\r\n\r\nThis is an issue, for example, if `myproperty` is an expensive call, has unwanted side effects, or excepts outside of a context manager\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-102449\n* gh-102592\n* gh-102593\n* gh-103034\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/chrisjsewell","@type":"Person","name":"chrisjsewell"},"datePublished":"2023-03-05T03:46:05Z","url":"https://github.com/python/cpython/issues/102433"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e3799242-da26-a03f-6c6c-8b6cc0276bdd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B56A:153A9C:905F24:CC5D35:6AFE1E19 |
| html-safe-nonce | abd7b6d550c518e27079b961639a6746d03c3b4b02b27c0c863a2eddb2805143 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTZBOjE1M0E5Qzo5MDVGMjQ6Q0M1RDM1OjZBRkUxRTE5IiwidmlzaXRvcl9pZCI6IjYxMjg3NDAwMTQ3MzQ4NDM0MTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dd4d584198cc122a29c71cfe94726988b2d07cc95c58a366f6426bec956dd165 |
| hovercard-subject-tag | issue:1610043426 |
| 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/102433/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a3ac807c4877d37f64c66b4fa6aa9daf27a4dac74cf330ad2b2596998668211f/python/cpython/issues/102433 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a3ac807c4877d37f64c66b4fa6aa9daf27a4dac74cf330ad2b2596998668211f/python/cpython/issues/102433 |
| og:image:alt | For example: from typing import Protocol, runtime_checkable @runtime_checkable class X(Protocol): @property def myproperty(self): ... class Y: @property def myproperty(self): raise RuntimeError("ha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chrisjsewell |
| hostname | github.com |
| expected-hostname | github.com |
| None | d0525ab1464526bf4532a5551aa348cf100dff75ef808a96fc67a08b1d946aa9 |
| 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 | fef3993a71fa20f7be8e167132fbf9619bc66e12 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width