Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created February 12, 2026 14:02
Show Gist options
  • Select an option

  • Save mypy-play/54f484ed23e70f7d771f08bf839f8e4e to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/54f484ed23e70f7d771f08bf839f8e4e to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Protocol, runtime_checkable
class P(Protocol):
def f(self) -> None: ...
@runtime_checkable
class RCP(Protocol):
def f(self) -> None: ...
class Impl:
def f(self) -> None:
return None
instance = Impl()
isinstance(instance, RCP)
isinstance(instance, runtime_checkable(P))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment