Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save mypy-play/65f08b7cf3cd4c961da47a8c2a1eb4b2 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