Created
November 15, 2025 19:49
-
-
Save mypy-play/833b8ba6dd71c9b46b18f8dfa8b2db79 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 * | |
| T = TypeVar("T", bound=int | float) | |
| class Adder(Protocol[T]): | |
| def add(self, x: T, y: T) -> T: | |
| ... | |
| class IntAdder(): | |
| def add(self, x: int, y: int) -> int: | |
| return x + y | |
| def add(adder: Adder): | |
| print(adder.add(2, 3)) | |
| add(IntAdder()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment