Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save mypy-play/2d99b0f746d714cd27da4ba85e0ae52e 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 | complex: ...
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