Skip to content

Mypy complains about lambda that returns None #1425

Closed
@JukkaL

Description

@JukkaL

Mypy gives a bogus error when giving a lambda that returns None when a callable returning None is expected:

from typing import Callable

def f(x: Callable[[], None]) -> None: pass

# Argument 1 to "f" has incompatible type Callable[[], None]; expected Callable[[], None]
f(lambda: None)  

Likely this is due to Void vs. NoneTyp, and we'd have to replace an inferred NoneTyp of a lambda expression with Void.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions