Mypy detects and reports overlapping function overloads that differ in return type.
In the example below, it correctly reports that the second overload of func1 overlaps the first overload. However, when the concrete type str is replaced by a generic type _T, it fails to report the error.
@overload
def func1(
a: str,
b: Literal[False] = ...,
) -> List[str]: ...
@overload
def func1(
a: str,
b: bool = ...,
) -> List[Union[str, int]]: ...
_T = TypeVar("_T")
@overload
def func2(
a: _T,
b: Literal[False] = ...,
) -> List[_T]: ...
@overload
def func2(
a: _T,
b: bool = ...,
) -> List[Union[_T, int]]: ...