(no title)
thr0w4w4y1337 | 5 months 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.
whilenot-dev|5 months ago
> Text after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.)
If you'd want monospace you should indent the snippet with two or more spaces:
amluto|5 months ago
sevensor|5 months ago
Generally it’s not worth trying to fix this stuff. The type signature is hell to write and ends up being super complex if you get it to work at all. Write a cast or Any, document why it’s probably ok in a comment, and move on with your life. Pick your battles.
dhussoe|5 months ago
ndriscoll|5 months ago
matusp|5 months ago
thr0w4w4y1337|5 months ago
dragonwriter|5 months ago
So, just:
is enough.