-
- Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Closed
Copy link
Labels
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 RuntimeError
This is an issue, for example, if myproperty 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
AndreiBarsan