Created
March 29, 2021 10:41
-
-
Save MartinThoma/d133f0102f588f695470680195370e91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Protocol | |
class SupportsClose(Protocol): | |
def close(self) -> None: | |
... | |
def finish_it(obj: SupportsClose): | |
obj.close() | |
class Foo: | |
def close(): | |
pass | |
foo = Foo() | |
finish_it(foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment