Skip to content

Generic function as first argument to map fails #3193

Closed
@JukkaL

Description

@JukkaL

From python/typeshed#1178:

map(tuple, [ [2, 3] ]) throws

error: Argument 1 to "map" has incompatible type Tuple[_T_co, ...]; expected Callable[[List[int]], Tuple[_T_co, ...]]

However, this is valid python code.

Here's a more self-contained example that reproduces the problem:

from typing import Callable, TypeVar

T = TypeVar('T')
S = TypeVar('S')

def f(fn: Callable[[T], S], x: T) -> None: pass
def g(x: T) -> T: pass

f(g, 1)  # Argument 1 to "f" has incompatible type Callable[[T], T]; expected Callable[[int], T]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions