mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🐞) Bad error message when invoking an overload with a bad call

Open KotlinIsland opened this issue 3 years ago • 0 comments

This sample produces two error messages, the second is completely valid, but the first makes no sense.

from typing import overload

@overload
def foo(a: list[int]): ...
@overload
def foo(a: list[object]): ...
def foo(a): ...

foo(dict[str, list[object]]()[1])
# Argument 1 to "foo" has incompatible type "list[object]"; expected "list[int]"
# Invalid index type "int" for "dict[str, list[object]]"; expected type "str"

playground

KotlinIsland avatar Aug 06 '22 14:08 KotlinIsland