Comment Comment by thr0w4w4y1337 from typing import Protocol, TypeVarT_co = TypeVar("T_co", covariant=True)class Indexable(Protocol[T_co]): def __getitem__(self, i: int) -> T_co: ...def f(x: Indexable[str]) -> None: print(x[0])I am failing to format it proprely here, but you get the idea. parent thr0w4w4y1337 1 year ago
T_co = TypeVar("T_co", covariant=True)
class Indexable(Protocol[T_co]): def __getitem__(self, i: int) -> T_co: ...
def f(x: Indexable[str]) -> None: print(x[0])
I am failing to format it proprely here, but you get the idea.