Skip to content

Argument ... has incompatible type "function"; expected Callable... #1983

Description

@jstasiak

I've looked for a similar report but couldn't find any - forgive me if there is one.

It seems to me that this code should pass type check:

from typing import Any, Callable


def fun() -> None:
    callbacks = [
        callback1,
        callback2,
    ]

    for c in callbacks:
        call(c, 1234)


def callback1(i: int) -> int:
    return i


def callback2(i: int) -> str:
    return 'hello'


def call(c: Callable[[int], Any], i: int) -> None:
    c(i)

mypy a284c48 doesn't like it:

test.py: note: In function "fun":
test.py:11: error: Argument 1 to "call" has incompatible type "function"; expected Callable[[int], Any]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions