Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Labels
Description
For example:
fromtypingimportProtocol,runtime_checkable@runtime_checkableclassX(Protocol):@propertydefmyproperty(self): ...classY:@propertydefmyproperty(self):raiseRuntimeError("hallo")isinstance(Y(),X)
will raise theRuntimeError
This is an issue, for example, ifmyproperty is an expensive call, has unwanted side effects, or excepts outside of a context manager
Linked PRs
- gh-102433: Add tests for how classes with properties interact with
isinstance()checks ontyping.runtime_checkableprotocols #102449 - [3.11] gh-102433: Add tests for how classes with properties interact with
isinstance()checks ontyping.runtime_checkableprotocols (GH-102449) #102592 - [3.10] gh-102433: Add tests for how classes with properties interact with
isinstance()checks ontyping.runtime_checkableprotocols (GH-102449) #102593 - gh-102433: Use
inspect.getattr_staticintyping._ProtocolMeta.__instancecheck__#103034