Closed
Description
In the following case, Mypy complains about an invalid signature for the foo
method in the implementation class, as it was missing an overload.
However, the missing overload is not applicable to that subclass and should not be requested.
from __future__ import annotations
from typing import overload, Generic, TypeVar
T = TypeVar("T")
class Interface(Generic[T]):
@overload
def foo(self: Interface[None]) -> int:
...
@overload
def foo(self, a: T) -> int:
...
def foo(self, a: T | None = None) -> str | int:
return 1
class Implementation(Interface[int]):
def foo(self, a: int) -> int:
return 2
Originally posted by @vnmabus in #13106 (comment)