mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🐞) Warn when overload impl default value is incompatible with overload part default value

Open KotlinIsland opened this issue 3 years ago • 0 comments

from typing import overload

@overload
def f(x: object): ...
@overload
def f(x: int = ...): ...

def f(x: object = ""): ...

While this code is type-safe, it's almost certainly a mistake. The default value of overload part 2 is never going to be met by the implementation.

  • related: https://github.com/python/mypy/issues/11397, but I think this issue is actually the same issue, just in a more generic form.

KotlinIsland avatar Aug 09 '22 01:08 KotlinIsland