Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created March 29, 2021 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/d133f0102f588f695470680195370e91 to your computer and use it in GitHub Desktop.
Save MartinThoma/d133f0102f588f695470680195370e91 to your computer and use it in GitHub Desktop.
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