Skip to content

Instantly share code, notes, and snippets.

@jorenham
Created February 28, 2026 20:28
Show Gist options
  • Select an option

  • Save jorenham/173951bb03b77e4fbd5032bb2833f2e3 to your computer and use it in GitHub Desktop.

Select an option

Save jorenham/173951bb03b77e4fbd5032bb2833f2e3 to your computer and use it in GitHub Desktop.
from typing import Protocol, Literal, reveal_type
class CanRMul[InT, OutT](Protocol):
def __rmul__(self, other: InT, /) -> OutT: ...
def twice[OutT](x: CanRMul[Literal[2], OutT]) -> OutT:
return 2 * x
reveal_type(twice("spam"))
[project]
name = "sandbox"
version = "0.1.0"
requires-python = ">=3.14"
dependencies = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment