Open
Description
With the following
from itertools import groupby
from typing import Iterator, Iterable, TypeVar, Callable, Tuple, Any
X, Key = TypeVar('X'), TypeVar('Key')
def sorted_groupby(sequence: Iterable[X], key: Callable[[X], Key]) -> Iterator[Tuple[Key, Iterator[X]]]:
return groupby(sorted(sequence, key=key), key=key)
You'll get
a.py:4: error: "object" not callable
a.py: note: In function "sorted_groupby":
a.py:5: error: Invalid type "a.X"
a.py:5: error: Invalid type "a.Key"
It would be nice if TypeVars didn't have restrictions compared to the full python syntax that can otherwise be used in non-typechecked code