Closed
Description
It would be handy to be able to specify a callable whose argument types are not checked but whose return type is, e.g., by specifying the argument types as None
instead of a list.
For example, consider map
:
def map(function, *iterables):
How would you annotate that? Trying to actually specify the argument types to function
to match the element types of the iterables in iterables
would require something horrible like C++11's parameter packs and variable-length type tuples. But just specifying Function
means there's no way to know that the result iterates values of the same type the function returns, which seems like a pity.
If you could just use None
or Any
instead of a list, you could do this:
def map(function: Function[None, T], *iterables: Iterable[Iterable]) -> Iterator[T]: