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: github.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 --\u003e\n### Linked PRs\n* gh-102449\n* gh-102592\n* gh-102593\n* gh-103034\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/chrisjsewell","@type":"Person","name":"chrisjsewell"},"datePublished":"2023-03-05T03:46:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":29},"url":"https://github.com/102433/cpython/issues/102433"}
| 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:38ba9ae7-0b84-fef4-5a5a-f6853adb4358 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C92:245D90:1BA045:24AFAD:6969D5C4 |
| html-safe-nonce | 9211c6969fc13cdf92f4eda6b99133e974c1662f87433ff19566d5a64ddf0daa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzkyOjI0NUQ5MDoxQkEwNDU6MjRBRkFEOjY5NjlENUM0IiwidmlzaXRvcl9pZCI6IjUzMTQwNTkxMTQ4MTc2NzM2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f9d3c9b189c278432f8dc8f9726aa45204bfd1b5436feda9a2f68d9ebc6d82c6 |
| 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 | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| 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 | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width