Skip to content

Support Callable[..., t] (with literal ellipsis, unspecified argument types and specified return type) #393

Closed
@abarnert

Description

@abarnert

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]:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions