Skip to content

Instantly share code, notes, and snippets.

@FFY00
Created October 6, 2021 13:37
Show Gist options
  • Save FFY00/4f01945c8fa54a95017918425a5364df to your computer and use it in GitHub Desktop.
Save FFY00/4f01945c8fa54a95017918425a5364df to your computer and use it in GitHub Desktop.
import typing
@typing.runtime_checkable
class SomeProtocol(typing.Protocol):
def foo(self): ...
class Hello:
def foo(self):
print('bar')
match Hello():
case SomeProtocol():
print('protocol!')
case _:
print('default :/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment