Created
February 12, 2026 14:02
-
-
Save mypy-play/54f484ed23e70f7d771f08bf839f8e4e to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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, 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