File size: 184 Bytes
5eb110b
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
from typing import runtime_checkable, Protocol

@runtime_checkable
class SupportsClose(Protocol):
    def close(self):
        ...

assert isinstance(open('some/file'), SupportsClose)