Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created November 15, 2025 19:49
Show Gist options
  • Select an option

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

Select an option

Save mypy-play/833b8ba6dd71c9b46b18f8dfa8b2db79 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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