Files
Semyon Proshev 0227f2747c Sync with typeshed @ 4af283e1aca6fc44a3b0d0b2e8a5d58f1f968cea
GitOrigin-RevId: aea01b944a9596f2af39d2a3532c8a06825f6e05
2019-07-04 21:00:18 +03:00

29 lines
920 B
Python

from typing import runtime_checkable, Protocol
@runtime_checkable
class Closable1(Protocol):
def close(self):
pass
class Closable2(Protocol):
def close(self):
pass
class ClosableImpl:
def close(self):
pass
assert isinstance(ClosableImpl(), Closable1)
assert issubclass(ClosableImpl, Closable1)
assert isinstance(ClosableImpl(), <error descr="Only @runtime_checkable protocols can be used with instance and class checks">Closable2</error>)
assert issubclass(ClosableImpl, <error descr="Only @runtime_checkable protocols can be used with instance and class checks">Closable2</error>)
assert isinstance(ClosableImpl(), <error descr="Only @runtime_checkable protocols can be used with instance and class checks">Protocol</error>)
B = Protocol
assert issubclass(ClosableImpl, <error descr="Only @runtime_checkable protocols can be used with instance and class checks">B</error>)