Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created March 9, 2026 19:05
Show Gist options
  • Select an option

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

Select an option

Save mypy-play/0759cd7e35f909e43193d2f1336ec8e5 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Protocol, Self
class FloatScalar[FloatT](Protocol):
def pow(self, arg: FloatT) -> Self: ...
def upcast(arg: FloatScalar[object]) -> FloatScalar[float]:
return arg # ✅️
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment