Skip to content

Inferring lambda doesn't seem to work on mypy 0.4.2 #1710

@cpdean

Description

@cpdean

Running mypy on the following file, lambdas.py:

from typing import Any, Callable
def apply(d, f):
    # type: (int, Callable[[Any], None]) -> None
    f(d)

apply(1, lambda x: None)

I get the error

lambdas.py:6: error: Argument 2 to "apply" has incompatible type Callable[[Any], None]; expected Callable[[Any], None]

It seems like mypy is having trouble inferring the right thing about the given inline lambda function with python 2 style annotations.

Also, the error message seems misleading because it's claiming the incompatible type is not the expected, but the error message says they're both the same thing.

mypy 0.4.2
python 3.5.0

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions